Environment Setup¶
lerd env sets up the .env file for a Laravel project in one command:
What it does¶
- Creates the env file from the framework's example file (e.g.
.env.examplefor Laravel,.env.distfor Symfony) if no env file exists yet - Detects which services the project uses — for Laravel, by inspecting env keys (
DB_CONNECTION,REDIS_HOST, etc.); for other frameworks, using the service detection rules defined in the framework definition - Writes lerd connection values for each detected service (hosts, ports, credentials) — preserving all comments and line order
- Creates the project database (and a
<name>_testingdatabase) inside the running service container; reports if they already exist - Starts any referenced service that is not already running
- Sets the app URL (
APP_URLfor Laravel; theurl_keydefined in the framework for others) to the project's registered.testdomain - Generates
APP_KEYviaphp artisan key:generateif the key is missing or empty (Laravel only) - Generates
REVERB_*values — ifBROADCAST_CONNECTION=reverbis detected, generatesREVERB_APP_ID,REVERB_APP_KEY,REVERB_APP_SECRET,REVERB_HOST,REVERB_PORT, andREVERB_SCHEMEusing random secure values for secrets
Example output¶
Creating .env from .env.example...
Detected mysql — applying lerd connection values
Detected redis — applying lerd connection values
Detected mailpit — applying lerd connection values
Setting APP_URL=http://my-app.test
Generating APP_KEY...
Done.
Safe to re-run¶
Running lerd env on a project that already has a .env is safe — it only updates connection-related keys and leaves everything else untouched.