Skip to content
prod e051e98
Browse

Environments — .env templates

One .env file per stage. They share the same shape, but a handful of keys flip as you move from your laptop to a live server — get those wrong and you either leak secrets or send real emails from a test box. The tabs below give you all three full files; the table first shows the keys that actually differ.

These are the keys to double-check every time. Everything else is broadly the same across files.

KeyLocalStagingProduction
APP_ENVlocalstagingproduction
APP_DEBUGtruefalsefalse
APP_URLhttp://your-project.testhttps://staging.your-domain.comhttps://your-domain.com
LOG_LEVELdebugdebugerror
LOG_STACKsingledailydaily
MAIL_MAILERlog (no real send)smtp (Mailtrap)smtp (live provider)
SESSION_ENCRYPTfalsefalsetrue
SESSION_SECURE_COOKIEtruetrue
Payment keyspk_test_ / sk_test_pk_live_ / sk_live_
TELESCOPE_ENABLEDtruetruefalse
DEBUGBAR_ENABLEDtruefalsefalse

A second gotcha shows up only once the file lives on a real server, where passwords and tokens contain special characters.

Each one carries a self-check at the bottom. Search for your- (local/staging) or the <...> markers (production) and replace.

.env (local development)
# ============================================================================
# 📋 LARAVEL LOCAL DEVELOPMENT ENVIRONMENT TEMPLATE
# ============================================================================
# Purpose: Local development environment configuration
# Server: Laravel Herd / Valet / Docker / MAMP / XAMPP
# Usage: Copy to project root as ".env"
# ============================================================================
#
# 🎯 LOCAL DEV CHARACTERISTICS:
# - APP_DEBUG=true (show detailed errors)
# - LOG_LEVEL=debug (verbose logging)
# - MAIL_MAILER=log (no real emails sent)
# - QUEUE_CONNECTION=sync (immediate execution)
# - Cache/Session use file driver (simple, no Redis needed)
#
# 💡 CUSTOMIZE: Search for "your-" and replace with your values
# ============================================================================
# App Identity
APP_NAME="Your App Name"
# Domain: your-project.test (Herd) or localhost:8000 (artisan serve)
APP_URL=http://your-project.test
# Environment Settings
APP_ENV=local
APP_DEBUG=true
APP_TIMEZONE=UTC
# Security Key (generated via: php artisan key:generate)
APP_KEY=
# Localization
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
# Logging — Local: show everything for debugging
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
# Database — Local MySQL (Herd/MAMP): root with no password on localhost
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=your_project_local
DB_USERNAME=root
DB_PASSWORD=
# OPTIONAL: SQLite for simple local dev
# DB_CONNECTION=sqlite
# DB_DATABASE=/absolute/path/to/database.sqlite
# Cache & Session — Local: use 'file' driver (no extra services)
CACHE_STORE=file
CACHE_PREFIX=
SESSION_DRIVER=file
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
# Queue & Broadcasting — Local: 'sync' runs jobs immediately
QUEUE_CONNECTION=sync
BROADCAST_CONNECTION=log
FILESYSTEM_DISK=local
# Redis (Optional for Local)
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
# Mail — Local: 'log' driver writes emails to storage/logs instead of sending
MAIL_MAILER=log
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@your-project.test"
MAIL_FROM_NAME="${APP_NAME}"
# AWS / S3 (Optional) — use local storage for dev, S3 only in staging/production
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
# Pusher / Websockets (Optional)
PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1
VITE_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
VITE_PUSHER_HOST="${PUSHER_HOST}"
VITE_PUSHER_PORT="${PUSHER_PORT}"
VITE_PUSHER_SCHEME="${PUSHER_SCHEME}"
VITE_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"
# Vite / Frontend build
VITE_APP_NAME="${APP_NAME}"
# Debug tooling (local only)
TELESCOPE_ENABLED=true
DEBUGBAR_ENABLED=true
# ============================================================================
# ✅ SETUP CHECKLIST
# ============================================================================
# [ ] 1. Copy this file to project root as ".env"
# [ ] 2. Run: php artisan key:generate
# [ ] 3. Create database: mysql -u root -e "CREATE DATABASE your_project_local"
# [ ] 4. Run: php artisan migrate
# [ ] 5. Update APP_NAME, APP_URL, DB_DATABASE with your project values
# [ ] 6. Test: php artisan serve OR access via Herd (your-project.test)
# ============================================================================

Once all three files are in place and the first migrate has run, the web-server layer is what locks everything down.