Search by

aaix / laravel-stack-env

aaix

A committed env layer for Laravel: .env.stack holds the defaults a project's stack dictates, the developer's .env only overrides them.

Package info

github.com/jonaaix/laravel-stack-env

pkg:composer/aaix/laravel-stack-env

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.3 2026-09-20 12:31 UTC

This package is auto-updated.

Last update: 2026-09-20 12:34:39 UTC


README

Laravel Stack Env Logo

Laravel Stack Env

Puts a committed .env.stack underneath every developer's .env — the stack configures itself, the personal file shrinks to secrets.

Latest Version on Packagist Total Downloads GitHub Actions License

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:

  1. Real environment variables — container, shell, CI
  2. .env — the developer's own file, not in version control
  3. .env.stack — committed, applies to everyone
  4. The env() fallback in config/*.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.