Health for Laravel
Environment Check
Environment Check
Verifies that all required environment variables are present.
Configuration
'checks_config' => [
'environment' => [
'required' => ['APP_KEY', 'DB_HOST', 'REDIS_HOST'],
],
],
Usage
use Cbox\LaravelHealth\Checks\EnvironmentCheck;
'checks' => [
'startup' => [
EnvironmentCheck::class,
],
],
Behavior
- Checks each variable in the
requiredarray with PHP'sgetenv(); a variable set to an empty string counts as present - Returns
okwhen all required variables exist - Returns
criticalwithmissingmetadata listing absent variables
When the configuration is cached (php artisan config:cache), Laravel doesn't load .env, so variables defined only in .env are not visible to getenv(). Set required variables in the real process environment (container env, systemd unit, PHP-FPM pool) when you cache config.