.env.dist.local [patched]
"scripts": "postinstall": "if [ ! -f .env.local ] && [ -f .env.dist.local ]; then cp .env.dist.local .env.local; fi"
Explicitly load the file in your bootstrap code (e.g., (new Dotenv())->loadEnv(__DIR__.'/.env.local'); ). Pitfall 2: Merge conflicts in .env.dist.local Cause: Multiple developers adding new variables simultaneously. .env.dist.local
### Local environment overrides .env.local .env.*.local !.env.dist.local # <-- IMPORTANT: whitelist the distribution file This ensures that .env.dist.local is tracked, but actual local overrides are NOT. In your README.md , add setup instructions: "scripts": "postinstall": "if [
Expect .env.dist.local to become a standard convention in next-generation boilerplates and project templates. It fills the role of a "local development manifesto" — a single, versioned file that says: "Here is exactly how to run this project on your machine, with plausible defaults." The .env.dist.local file is a small change with outsized impact. It eliminates guesswork, prevents configuration drift, and allows new team members to go from git clone to npm start in seconds — with zero broken configurations. ### Local environment overrides
Docker Compose already supports .env , but .env.dist.local keeps the blueprint in Git while .env.local stays local. Use Case 2: CI/CD Pipelines In your CI (GitHub Actions, GitLab CI, Jenkins), you don't want .env.dist.local to be used because CI should mimic production.