romanzipp/laravel-env-diff
A Laravel package for comparing .env files side by side, highlighting missing, extra, and mismatched keys so you can spot configuration drift between environments before it causes deployment surprises.
composer require --dev romanzipp/laravel-env-diff
config/app.php.php artisan vendor:publish --provider="RomanZipp\LaravelEnvDiff\EnvDiffServiceProvider"
php artisan list | grep -i env
php artisan env:diff --help
The command is env:diff. In 2.0 use --values to print variable values in addition to key presence.php artisan env:diff and copy anything missing from .env.example into your local .env. Make it the first step in onboarding and your post-merge routine.files array rather than additional_files, and the first file is compared against the second:
// config/env-diff.php
'files' => [
'.env',
'.env.example',
],
'path' => base_path(),
'show_values' => false,
Verify the default path for your layout before assuming root-level .env files are found.alias envdiff='php artisan env:diff'
Run it after git pull/composer update whenever .env.example changes. Treat .env.example as the source of truth and copy missing keys across..env.example is updated. Reviewers run the diff locally or in CI to catch keys referenced in config/*.php that were never documented..env.example plus a generated .env). Confirm the exit-code behavior first; if differences do not return non-zero, capture output and fail explicitly:
php artisan env:diff | tee env-diff.txt
test ! -s env-diff.txt
.env.example against the target environment's .env. This surfaces new keys that must be set in the deploy platform (Forge, Vapor, Kubernetes secrets) before the app boots.files array to compare non-default pairs in multi-environment setups:
'files' => ['.env.staging', '.env.example'],
Keep separate configs or wrap the command in a small script if you need several comparisons.composer.json:
"scripts": { "post-update-cmd": ["@php artisan env:diff"] }
Keep it non-blocking locally; developers can skip with --no-scripts.additional_files is gone. Republish or edit the config to use files, add the new path key, and decide on show_values. Clear cached config after editing (php artisan config:clear); stale cached config can hide the new keys.composer.json constraints before installing on Laravel 9/10/11; you may need --ignore-platform-reqs, a fork, or to vendor the small command class manually.--dev. Do not let a stale package block a framework upgrade.path default may surprise you. The shipped default is app_path(), which is not the application root. If your .env files live at the project root, set path to base_path() and clear config cache before relying on the diff.--values/show_values only when you need value visibility.--values and show_values => true can leak secrets into CI logs, PR comments, or terminal scrollback. Keep show_values false in committed config and pass --values manually only in trusted local sessions.export prefixes, whitespace, and ordering can produce misleading diffs. Normalize files or filter output before failing CI..env is gitignored, so the comparison only works where both files exist. In CI, generate .env from .env.example or provide a fixture before running the command.&& chaining will block a deploy — parse output explicitly.How can I help you explore Laravel packages today?