Laravel ENV Generator

Quickly generate a .env file for your Laravel project with a simple form.

  1. Home
  2. > Web Dev > Laravel Tools >
  3. ENV Generator

Generated .env

How to Use the Laravel ENV Generator

This tool helps you quickly create a .env file for your Laravel application. Follow these steps:

  1. Fill in the form — Expand each section (App Config, Database, Mail, etc.) and enter your environment values. Common defaults are pre-filled.
  2. Generate APP_KEY — Click the dice icon next to APP_KEY to generate a random base64 key, or paste an existing one.
  3. Watch it update — The generated .env content updates in real-time as you fill in the fields.
  4. Copy or Download — Click Copy to copy the content to your clipboard, or Download to save it as a .env file.
  5. Reset — Click Reset to restore all fields to their default values.

Tip

After generating your .env, run php artisan key:generate in your terminal if you left APP_KEY blank, or use the built-in generator above.

Frequently Asked Questions

What is a .env file in Laravel?

The .env file is Laravel's environment configuration file. It stores sensitive information like database credentials, API keys, and application settings outside your codebase. Laravel loads these values using the env() helper function and the config/ files.

Where should I place the .env file?

Place the .env file in the root directory of your Laravel project, alongside files like artisan, composer.json, and .gitignore. Laravel reads it automatically on every request.

Is it safe to commit .env to Git?

No. The .env file contains sensitive credentials and should never be committed to version control. Laravel's default .gitignore already excludes it. Instead, commit a .env.example file with placeholder values that other developers can copy and customize.

How do I generate an APP_KEY?

You can generate an APP_KEY using this tool's built-in generator (click the dice icon next to APP_KEY), or run php artisan key:generate in your terminal after placing the .env file. Laravel uses APP_KEY for encryption (cookies, session data, encrypted values).

What database connection options are available?

Laravel supports MySQL (port 3306), PostgreSQL (port 5432), SQLite (no host/port needed), and SQL Server (port 1433). Select your driver from the Database section and the default port will update automatically. For SQLite, you only need to set DB_DATABASE to the path of your database file.

What mail drivers does Laravel support?

Laravel supports SMTP (for Gmail, Mailtrap, SendGrid, etc.), Mailgun, Postmark, Amazon SES, Sendmail, and Log (writes to log files for testing). For local development, Log or a local SMTP server like Mailpit (port 1025) are common choices.