← All writing

Keep .env.example useful without committing secrets

Laravel 13 / PHP 8.3+Sources checked 2026-09-14

A new checkout boots only after someone copies a private production environment file. That is a sign the configuration contract is incomplete. .env.example should describe required names and safe defaults without containing live credentials.

Document configuration through placeholders

APP_ENV=local
APP_DEBUG=true
APP_URL=http://127.0.0.1:8000
MAIL_MAILER=log
SUPPLIER_API_URL=
SUPPLIER_API_TOKEN=

These are example values, not a production configuration. A log mailer is useful locally but must not be mistaken for delivered email. Leave secrets blank and explain optional integrations in setup documentation.

Separate required startup from optional services

A portfolio should not fail to render because an optional advertising identifier is absent. Conversely, a payment operation should fail clearly when its required credentials are missing. Define those boundaries rather than scattering env() fallbacks through controllers.

Read environment values through configuration files and use config() in application code, especially when configuration is cached. After changing production configuration, rebuild the appropriate cache using the correct runtime.

Test a fresh installation using only the documented example and setup steps. Do not include .env, database dumps, private keys, or debug exports in a Git push. If a credential was committed previously, removing it in a later commit does not revoke it; rotate the exposed credential through the provider. A useful example file reduces the pressure to share a real one.

Reference

Official documentation.