phpdmitry / laravel-env-check
Check that an environment file contains the keys required by .env.example without exposing values.
Requires
- php: ^8.3
- illuminate/console: ^12.0|^13.0
- illuminate/support: ^12.0|^13.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^10.0|^11.0
- pestphp/pest: ^3.0|^4.0
- pestphp/pest-plugin-laravel: ^3.0|^4.0
README
Laravel Env Check is a small Laravel package for development and CI. It checks whether a target environment file has every key declared in .env.example, without comparing or displaying secret values.
Installation
Vendor replacement point: before publishing, replace the vendor segment in
nameincomposer.json. This is the single source of truth for the package vendor.
composer require --dev <your-vendor>/laravel-env-check
Laravel discovers the service provider automatically through Composer package discovery. No manual provider registration is needed.
Usage
php artisan env:check php artisan env:check --file=.env.production php artisan env:check --ignore=APP_DEBUG,LOG_LEVEL
The command uses .env.example as the required-key list and .env as its default target. It only reports key names and statuses:
--file accepts a relative path inside the Laravel application base directory. Paths that are absolute, contain .., or resolve outside that directory are rejected.
+-----------+---------+
| Key | Status |
+-----------+---------+
| APP_KEY | present |
| APP_DEBUG | empty |
| LOG_LEVEL | missing |
+-----------+---------+
Problems: 2
It exits with 0 when every non-ignored key is present and non-empty, otherwise 1. A missing target file also produces a clear error and exit code 1.
CI
- run: composer install --no-interaction --prefer-dist - run: php artisan env:check --file=.env.ci
Why not a simple diff?
A plain diff compares values and can disclose secrets in CI output. This package compares only the required set of keys from .env.example; it never compares, prints, logs, or loads target values into the process environment.
Limitations
This package intentionally checks only key presence and empty values. It does not create or modify env files, type-cast values, validate connections, fetch secrets from Vault, or provide a web UI.
Security note
Treat .env files as sensitive. The command reads the target file directly and keeps values inside the parser only long enough to determine each status. Do not enable verbose shell tracing around commands that include secret-bearing paths or options.