stefanocbt / phpdotenv-sync
A package that makes sure that your .env file is in sync with your .env.example
Installs: 21 302
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- vlucas/phpdotenv: ^5.2
Requires (Dev)
- mikey179/vfsstream: ^1.6
- mockery/mockery: ^1.4
- phpstan/phpstan: ^1.9
- phpunit/phpunit: ^9.3
- squizlabs/php_codesniffer: ^3.5
- wapmorgan/php-deprecation-detector: ^2.0
README
phpdotenv-sync
A package that makes sure that your .env file is in sync with your .env.example
Usage
add the library to your project with composer:
composer require stefanocbt/phpdotenv-sync
using the library: phpdotenv-sync has the following operations:
- check: to check diffs between two dotenv files (Example: .env.example and .env)
- sync: to sync two dotenv files (add missing dotenv parameters to destination dotenv file)
Executing:
./vendor/bin/phpdotenvsync [options]
Options:
--opt[=OPT] Specify the right operation (Required) ("check" or "sync")
--src[=SOURCE] Specify the source dotenv file (Optional) (default: current-folder-path/.env.example)
--dest[=DESTINATION] Specify the destination dotenv file (Optional) (default: current-folder-path/.env)
--no-interaction Avoid all kind of user interactions. Default action is to syncing by copying all parameters with their default values (Optional)
if you are in a standard environment and you have .env.example and .env inside the root project folder you can just execute the following command to sync .env.example and .env files:
./vendor/bin/phpdotenvsync --opt=sync
for --src and --dest options you can use absolute and/or relative paths. If, for example, you have the files inside the current pwd folder but dotenv files have different filenames you can launch phpdotenvsync this way:
./vendor/bin/phpdotenvsync --opt=sync --src=./[SRC_FILENAME] --dest=./[DEST_FILENAME]
or if you want to specify an absolute path:
./vendor/bin/phpdotenvsync --opt=sync --src=/absolute/path/to/[SRC_FILENAME] --dest=/absolute/path/to/[DEST_FILENAME]
Development
testing CHECK command into development environment (execute from project root dir):
php bin/phpdotenvsync --opt=check --src="./bin/dev_testing/.env.example" --dest="./bin/dev_testing/.env"
testing SYNC command into development environment (execute from project root dir):
php bin/phpdotenvsync --opt=sync --src="./bin/dev_testing/.env.example" --dest="./bin/dev_testing/.env"
Codequality tests
phpcs
automatic fix with phpcs:
php vendor/bin/phpcbf --standard=PSR12 -n -p src/