Fail fast on bad environment variables

Declare the variables your PHP or Laravel app needs — types, allowed values, per-environment rules — using the validation rules you already know. Catch mistakes at boot or in CI, not three screens into a user flow.

composer require jfrintrop/env-validator

See it work

Real output from the package — pick a scenario.

Schema
EnvValidator::make([
    'APP_ENV'   => 'required|in:local,staging,production',
    'APP_DEBUG' => 'required|boolean',
    'DB_PORT'   => 'required|integer|between:1,65535',
])->validate();
Environment: APP_ENV=prod, DB_PORT=abc
Environment validation failed with 2 problems:
  - The APP_ENV environment variable must be one of: local, staging, production.
  - The DB_PORT environment variable must be an integer.

Why use it

Rules you know

Laravel validation syntax under the hood — no new DSL.

Env-aware

Handles true/false/null/empty and quoted values like env() does.

Per-environment rules

Stricter requirements for production, relaxed for local.

CI friendly

Proper exit codes for env:validate and env:example --check.

Typed values

Opt in to int, float and bool results.

Works standalone

The core needs no framework — any PHP 8.1+ project.