aaix / laravel-stack-env
A committed env layer for Laravel: .env.stack holds the defaults a project's stack dictates, the developer's .env only overrides them.
Requires
- php: >=8.4
- laravel/framework: ^13.0
- vlucas/phpdotenv: ^5.0
Requires (Dev)
- pestphp/pest: ^3.7|^4.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-20 12:34:39 UTC
README
Laravel Stack Env
Puts a committed .env.stack underneath every developer's .env — the stack configures
itself, the personal file shrinks to secrets.
Database driver, service hostnames, ports, queue and mail transport are the same for everyone
working on a project — they follow from its stack, not from who checked it out. Put them in a
committed .env.stack and a fresh clone runs without a single manual setting. Nobody's .env
repeats them, .env.example stops listing them, and no config/*.php has to be touched.
Highest wins:
- Real environment variables — container, shell, CI
.env— the developer's own file, not in version control.env.stack— committed, applies to everyone- The
env()fallback inconfig/*.php
Every key is decided on its own: .env overrides exactly the keys it defines and leaves the rest
of .env.stack in place.
Setup
composer require aaix/laravel-stack-env
1. Register the loader in bootstrap/app.php. On the slim skeleton the file returns the
builder expression directly, so assign it first:
$app = Application::configure(basePath: dirname(__DIR__)) // ... ->create(); $app->singleton( \Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class, \Aaix\LaravelStackEnv\LoadEnvironmentVariables::class, ); return $app;
On the classic skeleton $app already exists — put the same singleton() call next to the other
bindings, above return $app;.
2. Create .env.stack in the project root and commit it. Make sure .gitignore does not
swallow it: a .env* pattern would, and the layer only reaches your colleagues and CI once the
file is in the repository.
DB_CONNECTION=mysql DB_HOST=mysql REDIS_HOST=redis QUEUE_CONNECTION=redis
That is the whole integration. Check it with php artisan config:show database.
License
MIT.