Developer tool

Laravel .env Generator

Pick your database, cache, queue, session, mail and filesystem drivers and get a ready .env with a secure random APP_KEY and a plain-English note for every key.

Free, no sign-up. Runs in your browser; nothing is uploaded.

Application

Drivers

Database credentials

.env file

# ---- Application (config/app.php) ----
# Shown in emails and notifications.
APP_NAME="My App"
# Environment name. Use production on live servers.
APP_ENV=local
# Encrypts cookies, sessions and encrypted columns. Keep it secret and never change it on a live app without a rotation plan.
APP_KEY=
# Shows stack traces. Must be false in production, or secrets can leak.
APP_DEBUG=true
# Base URL used by artisan, queued jobs and generated links.
APP_URL=http://localhost
# Default language for translations.
APP_LOCALE=en
# Used when a translation is missing.
APP_FALLBACK_LOCALE=en
# Password hashing cost. Higher is slower and safer.
BCRYPT_ROUNDS=12

# ---- Logging (config/logging.php) ----
# Where logs go: stack, single file, daily files or stderr (containers).
LOG_CHANNEL=stack
# Lowest severity that gets written.
LOG_LEVEL=debug

# ---- Database (config/database.php) ----
# Database driver.
DB_CONNECTION=mysql
# Database server host name.
DB_HOST=127.0.0.1
# Database server port.
DB_PORT=3306
# Database name. Create it first.
DB_DATABASE=laravel
# Use a dedicated user with only the rights the app needs, not root.
DB_USERNAME=laravel
# Database password. Use a long random value.
DB_PASSWORD=

# ---- Session (config/session.php) ----
# Where sessions live. "database" needs php artisan session:table (included in new apps).
SESSION_DRIVER=database
# Minutes of inactivity before a session expires.
SESSION_LIFETIME=120
# Set true to encrypt the session payload.
SESSION_ENCRYPT=false

# ---- Cache (config/cache.php) ----
# Cache driver. Redis is fastest for most production apps; "database" needs no extra service.
CACHE_STORE=database

# ---- Queue (config/queue.php) ----
# Run a worker with php artisan queue:work (use Supervisor in production).
QUEUE_CONNECTION=database

# ---- Mail (config/mail.php) ----
# Writes emails to the log instead of sending. Ideal for development.
MAIL_MAILER=log
# Default From address. Must be on a domain you have verified.
MAIL_FROM_ADDRESS=hello@example.com
# Default From name; reuses APP_NAME.
MAIL_FROM_NAME="${APP_NAME}"

# ---- Filesystem (config/filesystems.php) ----
# Private files under storage/app/private.
FILESYSTEM_DISK=local

The key is generated in your browser with the Web Crypto API. Copy copies the real values even when secrets are hidden. Never commit .env to Git.

Next steps

php artisan migrate
php artisan queue:work --tries=3

What each key does

Application config/app.php

APP_NAME
Shown in emails and notifications.
APP_ENV
Environment name. Use production on live servers.
APP_KEY
Encrypts cookies, sessions and encrypted columns. Keep it secret and never change it on a live app without a rotation plan.
APP_DEBUG
Shows stack traces. Must be false in production, or secrets can leak.
APP_URL
Base URL used by artisan, queued jobs and generated links.
APP_LOCALE
Default language for translations.
APP_FALLBACK_LOCALE
Used when a translation is missing.
BCRYPT_ROUNDS
Password hashing cost. Higher is slower and safer.

Logging config/logging.php

LOG_CHANNEL
Where logs go: stack, single file, daily files or stderr (containers).
LOG_LEVEL
Lowest severity that gets written.

Database config/database.php

DB_CONNECTION
Database driver.
DB_HOST
Database server host name.
DB_PORT
Database server port.
DB_DATABASE
Database name. Create it first.
DB_USERNAME
Use a dedicated user with only the rights the app needs, not root.
DB_PASSWORD
Database password. Use a long random value.

Session config/session.php

SESSION_DRIVER
Where sessions live. "database" needs php artisan session:table (included in new apps).
SESSION_LIFETIME
Minutes of inactivity before a session expires.
SESSION_ENCRYPT
Set true to encrypt the session payload.

Cache config/cache.php

CACHE_STORE
Cache driver. Redis is fastest for most production apps; "database" needs no extra service.

Queue config/queue.php

QUEUE_CONNECTION
Run a worker with php artisan queue:work (use Supervisor in production).

Mail config/mail.php

MAIL_MAILER
Writes emails to the log instead of sending. Ideal for development.
MAIL_FROM_ADDRESS
Default From address. Must be on a domain you have verified.
MAIL_FROM_NAME
Default From name; reuses APP_NAME.

Filesystem config/filesystems.php

FILESYSTEM_DISK
Private files under storage/app/private.

How to use the laravel .env generator

Generate a .env you can trust

Laravel reads its settings from a .env file, and the config files under config/ decide how those values are used. This tool writes the .env side for you and explains each key, so you can move from install to a working app quickly.

1. Set the basics

Give the app a name, pick the environment and enter the URL. Production automatically turns debug off and lowers the log level, because debug pages show environment values and stack traces to anyone who triggers an error.

2. Choose your drivers

  • Database: MySQL, MariaDB, PostgreSQL, SQLite or SQL Server. The port fills in for you, and a strong random password is suggested for the database user.
  • Cache, queue and session: pick database for a zero-extra-services setup or redis for speed. Choosing Redis adds the REDIS_* block.
  • Mail: log writes emails to the log, perfect for development. Other options add the keys that provider needs.
  • Filesystem: local private, local public (remember php artisan storage:link) or S3-compatible storage.

3. Check the explanations

The panel at the bottom lists each key with the config file that reads it and a short note. Use it as a checklist when you set up staging or hand the project to a colleague.

4. Copy or download

Download the file as .env and drop it in your project root. The Next steps box lists the artisan and composer commands your choices need, such as running migrations or starting a queue worker.

Security habits

  1. Keep .env out of Git. Commit a .env.example with empty secrets instead.
  2. Use a separate database user per app, with only the privileges it needs.
  3. Run php artisan config:cache in production, and note that once config is cached, env() works only inside config files.
  4. Rotate keys and passwords if a file is ever shared by mistake.

Frequently asked questions

How is the APP_KEY generated?

In your browser, using the Web Crypto random generator. It creates 32 random bytes and writes them as base64 with the "base64:" prefix, which is exactly what php artisan key:generate produces for Laravel's AES-256-CBC cipher. Nothing is sent anywhere.

Can I use this key in production?

Yes, it is cryptographically random, so it is as strong as one made by artisan. Store it in your secrets manager, never commit the .env file, and do not regenerate it on a live app unless you plan for the sessions and encrypted data it protects.

Which Laravel versions does it match?

The key names follow Laravel 11 and 12 (for example CACHE_STORE and MAIL_SCHEME). Most keys are the same in Laravel 10, but older apps use CACHE_DRIVER instead of CACHE_STORE.

Which queue and cache drivers should I choose?

For a small app, the database driver needs no extra service. Choose Redis when you need speed or many workers. Use sync only locally, because it runs jobs inside the web request.

Why is my password hidden?

Secret values are masked on screen so shoulder-surfers and screen shares do not see them. Tick "Show secrets" to reveal them. The Copy and Download buttons always use the real values.