Format .env files according to your .env.example structure to keep track of used and unused variables.
I like to keep a clear overview of all available environment variables by adding some default values to my version controled .env.example file.
This packages helps with structuring your example files.
composer require romanzipp/laravel-env-normalizer --devphp artisan env:normalizephp artisan env:normalize --helpReference and target options are optional. If not specified the command will only look for a .env.example (as reference) and .env file (as target).
php artisan env:normalize --reference=.env.example --target=.env --target=.env.localThis option will discover any other .env.* files located in the base path and add them to the target list.
php artisan env:normalize --autoThis will create a {name}.bak backup file for each modified target file.
php artisan env:normalize --backupLog the expected output to the console instead of writing it to the file.
php artisan env:normalize --dry.env.example |
previous .env |
new .env |
|---|---|---|
BASE_URL=localhost |
DB_HOST=10.0.0.10 |
BASE_URL=me.com |
- The base structure for all target
.envfiles will be taken from the reference.env.examplefile - Values will be replaced with the existing content
- Unused (not overwritten) example variables will not be added
- Additional variables from the
.envfile will be appended to the bottom so you can later add them to your version controled example file - Commented lines
#FOO=barwhich do not start with hash + space#will be appended to the end
- Detect similar variables and position them below existing ones (place
MAIL_FROMbelowMAIL_CONNECTIONinstead of appendin it to the end)
./vendor/bin/phpunit