CACHE_DRIVER=file SESSION_DRIVER=file
| Variable Group | Variable Name | Description | Production Importance |
| :--- | :--- | :--- | :--- |
| Application | APP_ENV | Current environment (local, staging, production). | Critical |
| | APP_DEBUG | Displays detailed errors. Must be false in production. | Critical (Security) |
| | APP_KEY | 32-bit random string used for encryption & sessions. Set via php artisan key:generate. | Critical |
| | APP_URL | The base URL of the application. | Important |
| Database | DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, DB_PASSWORD | Credentials for the primary database connection. | Critical |
| Session | SESSION_DRIVER | (file, cookie, redis, database). redis is best for production scaling. | Important |
| Cache | CACHE_DRIVER | (file, redis, memcached, database). | Important |
| Queue | QUEUE_CONNECTION | (sync, redis, database). Set to redis or database for async jobs. | Important |
| Mail | MAIL_HOST, MAIL_USERNAME, MAIL_PASSWORD, MAIL_ENCRYPTION | Credentials for sending emails (e.g., Mailgun, SES, SMTP). | Critical |
| Services (API) | SERVICES_KEY, SERVICES_SECRET | Keys for third-party APIs (Stripe, AWS, Twilio, etc.). | Critical |
Do not store massive blocks of JSON or complex data structures in .env. It is designed for flat, primitive values. If complex configuration is needed, store a path to a config file or use the config/ directory structures to parse the value.
A small Laravel app uses a .env file to store configuration. One night, a junior developer accidentally committed it to the repository. Secrets leaked, the app failed, and the team raced to recover.