justcoded / dotenv-sync
Installs: 26 367
Dependents: 1
Suggesters: 0
Security: 0
Stars: 3
Watchers: 4
Forks: 4
Open Issues: 0
Requires
- php: >=5.4
- vlucas/phpdotenv: ^2.5
This package is auto-updated.
Last update: 2023-10-15 23:31:11 UTC
README
The package is intended for avoiding problems with .env and .env.example files content mismatch.
Installation
Start by requiring the package with composer:
composer require justcoded/dotenv-sync
or add it to your composer.json
and run composer update
Usage
Add the next line to your git pre-commit hooks (.git/hooks/pre-commit
) to prevent committing
if .env
has params missed in .env.example
and vice versa.
Ensure the file vendor/bin/dotenv-diff
is executable.
exec vendor/bin/dotenv-diff {envFileName} {envExampleFileName}
We also recommend to use this package to manage your git hooks inside composer.json: https://github.com/BrainMaestro/composer-git-hooks
To make bin scripts executable just run:
chmod +x vendor/bin/dotenv-diff vendor/bin/dotenv-sync
To sync missing variables to your .env
and .env.example
files run the next command
vendor/bin/dotenv-sync {envFileName} {envExampleFileName}
Also you can notify about diff on composer install
. To do this add such script to your
composer.json
:
{ // ... "scripts": { "post-install-cmd": [ "dotenv-diff" ], "post-update-cmd": [ "dotenv-diff" ] }