2017 © Pedro Peláez
 

library env-diff

Check the difference between env files and actualize each other

image

tekill/env-diff

Check the difference between env files and actualize each other

  • Friday, April 20, 2018
  • by Tekill
  • Repository
  • 1 Watchers
  • 4 Stars
  • 2,265 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 14 % Grown

The README.md

EnvDiff

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score, (*1)

EnvDiff is tool to compare environment keys to find the difference between .env files and actualize them., (*2)

Example cast, (*3)

Installation

composer require tekill/env-diff

Manual running

Actualize variables

Compare .env with .env.dist and add missing variables to .env file., (*4)

php ./vendor/bin/env-diff actualize

Compare .env with .env.example and add missing variables to .env file., (*5)

php ./vendor/bin/env-diff actualize .env.example

Compare .env-target with .env.example and add missing variables to .env-target file., (*6)

php ./vendor/bin/env-diff actualize .env.example .env-target

If you want to delete outdated values just run command with -k=false option., (*7)

php ./vendor/bin/env-diff actualize -k=false

Show differences

Command has same interface, arguments and options., (*8)

Compare .env with .env.dist and show differences between them., (*9)

php ./vendor/bin/env-diff diff

Composer script

Add code block in composer.json: ```$json "scripts": { "post-update-cmd": "LF\EnvDiff\Composer\ScriptHandler::actualizeEnv" }, (*10)


The `.env` will then be created or updated by the composer script, to match the structure of the dist file `.env.dist` by asking you the missing variables. By default, the dist file is assumed to be in the same place than the target `.env` file, suffixed by `.dist`. This can be changed in the configuration: ```json { "extra": { "lf-env-diff": [ { "dist": "path/to/env.dist", "target": "path/to/.env" } ] } }

The script handler will ask you interactively for variables which are missing in the target env file, using the value of the dist file as default value. If composer is run in a non-interactive mode --no-interaction, the values of the dist file will be used for missing variables., (*11)

Warning: This handler will overwrite any comments or spaces into your target .env file so handle with care., (*12)

Managing multiple ignored files

The handler can manage multiple ignored files. To use this feature, the lf-env-diff extra should contain a JSON array with multiple configurations inside it instead of a configuration object:, (*13)

{
    "extra": {
        "lf-env-diff": [
            {
                 "dist": "path/to/.env.dist",
                 "target": "path/to/.env"
            },
            {
                 "dist": "path/to/.env.dist",
                 "target": "path/to/.env-test",
                 "keep-outdated": false
            }
        ]
    }
}

Show difference

Add code block in composer.json: ```$json "scripts": { "post-update-cmd": "LF\EnvDiff\Composer\ScriptHandler::showDifference" }, (*14)


This handler has same behavior as described before. ## Git hooks You can use Git hook that gets triggered after any 'git pull' whenever one of the files specified has changed. Useful to update any web application dependency or sync configuration. Create `post-merge` hook in `.git/hooks` directory of your project:

/usr/bin/env bash

changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)", (*15)

check_run() { echo "$changed_files" | grep -E --quiet "$1" && eval "$2" }, (*16)

Actualize env files if the env.dist file gets changed

check_run env.dist "php ./vendor/bin/env-diff actualize" ```, (*17)

The Versions

20/04 2018

dev-master

9999999-dev

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde

20/04 2018

1.1.0

1.1.0.0

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde

30/09 2017

dev-add-code-climate

dev-add-code-climate

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde

31/08 2017

1.0.3

1.0.3.0

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde

05/06 2017

1.0.2

1.0.2.0

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde

01/06 2017

1.0.1

1.0.1.0

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde

14/05 2017

1.0.0

1.0.0.0

Check the difference between env files and actualize each other

  Sources   Download

MIT

The Requires

 

The Development Requires

by Lexey Felde