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.

Application
Database
SQLite needs no other keys. Laravel uses database/database.sqlite.
Sessions, cache and queue
Mail
${APP_NAME} reuses the application name.
File storage
.env

After you save it
  1. Run php artisan key:generate to fill in APP_KEY.
  2. Run php artisan migrate. The database session, cache and queue drivers need their tables.
  3. 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 appsLaravel 13Read by
CACHE_DRIVERCACHE_STOREconfig/cache.php
MAIL_ENCRYPTIONMAIL_SCHEMEconfig/mail.php
BROADCAST_DRIVERBROADCAST_CONNECTIONconfig/broadcasting.php
FILESYSTEM_DRIVERFILESYSTEM_DISKconfig/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$$word stays 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

  • .env is where credentials belong, and it stays out of version control. Laravel's .gitignore already excludes it.
  • Commit .env.example with the keys and no secrets, so a teammate knows what to fill in.
  • To ship an environment file with a deploy, php artisan env:encrypt produces an encrypted copy that is safe to commit.
  • In production run php artisan config:cache. After that, env() returns null outside the config files, so read settings with config() 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
The Stack Toast admin dashboard with revenue and subscription metrics