Laravel .env generator
Build a .env file that matches a fresh Laravel 13 app. Pick your database, cache, queue and mail setup, and copy the result. Everything runs in your browser.
- Run
php artisan key:generateto fill inAPP_KEY. - Run
php artisan migrate. The database session, cache and queue drivers need their tables. - Keep the file out of git. Nothing you type here leaves your browser.
What changed in the key names
Several keys were renamed in Laravel 11 and keep their new names in Laravel 13. An old key is not an error. Laravel ignores it and uses the default, which is why a copied .env can look right and still do the wrong thing.
| Older apps | Laravel 13 | Read by |
|---|---|---|
CACHE_DRIVER | CACHE_STORE | config/cache.php |
MAIL_ENCRYPTION | MAIL_SCHEME | config/mail.php |
BROADCAST_DRIVER | BROADCAST_CONNECTION | config/broadcasting.php |
FILESYSTEM_DRIVER | FILESYSTEM_DISK | config/filesystems.php |
MAIL_SCHEME is not a rename of the old values. It accepts smtp or smtps, and tls is not valid. Leave it as null and Laravel chooses for you: smtps on port 465, STARTTLS elsewhere when the server offers it.
Quoting values
A value with a space, a # or a quote must be quoted, or it is cut short or misread. This generator quotes for you:
- Plain values are written as they are.
- A value with special characters goes in single quotes, where nothing is interpreted. A password such as
pa$$wordstays exactly that. - Double quotes are used only where a variable reference such as
${APP_NAME}should be expanded.
What the defaults assume
A fresh Laravel 13 app uses SQLite, and stores sessions, cache and queued jobs in the database. That works on one server without Redis. Move the cache and queue to Redis when you run more than one server or need Horizon.
The sync queue runs jobs inside the request. It suits tests and local work. In production it makes the user wait for every email and webhook.
Keeping secrets safe
.envis where credentials belong, and it stays out of version control. Laravel's.gitignorealready excludes it.- Commit
.env.examplewith the keys and no secrets, so a teammate knows what to fill in. - To ship an environment file with a deploy,
php artisan env:encryptproduces an encrypted copy that is safe to commit. - In production run
php artisan config:cache. After that,env()returnsnulloutside the config files, so read settings withconfig()in your own code. Do not cache config during local development.
Sources: Laravel 13 configuration, mail, and the .env.example of a new Laravel 13 app.
Building a SaaS on Laravel? Start with the foundation already built.
Stack Toast is a Laravel 13 starter kit with authentication, billing through four payment processors, teams and a complete admin panel. Choose Livewire, React, Vue or API.
- From $199, one payment
- Full GitHub source
- Unlimited projects
- 30-day money-back guarantee
