A package that makes sure that your .env file is in sync with your .env.example
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)
./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]
php bin/phpdotenvsync --opt=check --src="./bin/dev_testing/.env.example" --dest="./bin/dev_testing/.env"
php bin/phpdotenvsync --opt=sync --src="./bin/dev_testing/.env.example" --dest="./bin/dev_testing/.env"
automatic fix with phpcs:
php vendor/bin/phpcbf --standard=PSR12 -n -p src/