romanzipp / laravel-env-normalizer
Format .env files according to your .env.example structure to keep track of used and unused variables
Fund package maintenance!
romanzipp
Installs: 6 252
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: ^8.0
- illuminate/database: ^5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
- illuminate/support: ^5.4|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.0
- mockery/mockery: ^1.3.2
- orchestra/testbench: >=3.8
- phpstan/phpstan: ^0.12.99|^1.0
- phpunit/phpunit: ^7.0|^8.0|^9.0
- romanzipp/php-cs-fixer-config: ^3.0
README
Format .env
files according to your .env.example
structure to keep track of used and unused variables.
Why?
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.
Contents
Installation
composer require romanzipp/laravel-env-normalizer --dev
Usage
php artisan env:normalize
List all available options
php artisan env:normalize --help
Specify reference and target file(s)
Reference 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.local
Automatically format all other .env files
This option will discover any other .env.*
files located in the base path and add them to the target list.
php artisan env:normalize --auto
Create backup files
This will create a {name}.bak
backup file for each modified target file.
php artisan env:normalize --backup
Dry run
Log the expected output to the console instead of writing it to the file.
php artisan env:normalize --dry
Example normalization
- The base structure for all target
.env
files will be taken from the reference.env.example
file - Values will be replaced with the existing content
- Unused (not overwritten) example variables will not be added
- Additional variables from the
.env
file will be appended to the bottom so you can later add them to your version controled example file - Commented lines
#FOO=bar
which do not start with hash + space#
will be appended to the end
Roadmap
- Detect similar variables and position them below existing ones (place
MAIL_FROM
belowMAIL_CONNECTION
instead of appendin it to the end)
Testing
./vendor/bin/phpunit