Skip to main content

Environment Configuration

MediaStream uses a .env file for environment-specific configuration. This file is created from .env.example during installation.
1

Create environment file

If you haven’t already, copy the example file:
cp .env.example .env
2

Generate application key

Generate a unique application key:
php artisan key:generate
This sets the APP_KEY value in your .env file.

Core Application Settings

Application Identity

.env
APP_NAME=Laravel
APP_ENV=local
APP_KEY=
APP_DEBUG=true
APP_URL=http://localhost
APP_NAME
string
default:"Laravel"
Your application name. This appears in:
  • Page titles
  • Email notifications
  • Default branding
APP_NAME="MediaStream"
APP_ENV
string
default:"local"
Application environment. Common values:
  • local - Development
  • staging - Pre-production
  • production - Live environment
Never use local or staging in production!
APP_KEY
string
required
Encryption key for securing session data and encrypted values.Generated automatically with php artisan key:generate.
APP_DEBUG
boolean
default:"true"
Enable detailed error messages and debugging tools.
ALWAYS set to false in production to prevent information disclosure.
# Development
APP_DEBUG=true

# Production
APP_DEBUG=false
APP_URL
string
default:"http://localhost"
The base URL of your application. Used for:
  • Generating links in emails
  • Asset URL generation
  • API responses
# Local development
APP_URL=http://localhost:8000

# Production
APP_URL=https://mediastream.example.com

Localization

.env
APP_LOCALE=en
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE=en_US
APP_LOCALE
string
default:"en"
Default application language.
APP_FALLBACK_LOCALE
string
default:"en"
Language to use when the requested locale is unavailable.
APP_FAKER_LOCALE
string
default:"en_US"
Locale for generating fake data in tests and seeders.

Maintenance Mode

.env
APP_MAINTENANCE_DRIVER=file
# APP_MAINTENANCE_STORE=database
APP_MAINTENANCE_DRIVER
string
default:"file"
Storage driver for maintenance mode state:
  • file - Store in filesystem
  • database - Store in database
  • cache - Store in cache

Security Settings

Encryption

.env
BCRYPT_ROUNDS=12
BCRYPT_ROUNDS
integer
default:"12"
Number of rounds for bcrypt password hashing.Higher values = more secure but slower:
  • 10 - Fast, less secure
  • 12 - Balanced (recommended)
  • 14+ - Slower, more secure

Database Configuration

MediaStream supports multiple database systems:
.env
DB_CONNECTION=sqlite
# DB_HOST=127.0.0.1
# DB_PORT=3306
# DB_DATABASE=laravel
# DB_USERNAME=root
# DB_PASSWORD=
SQLite requires no additional configuration. Just ensure the database file exists:
touch database/database.sqlite
php artisan migrate
SQLite is perfect for development but consider MySQL/PostgreSQL for production.

Session Configuration

.env
SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false
SESSION_PATH=/
SESSION_DOMAIN=null
SESSION_DRIVER
string
default:"database"
Where to store session data:
  • file - Filesystem storage
  • cookie - Browser cookies
  • database - Database storage (recommended)
  • redis - Redis cache
  • memcached - Memcached cache
Database sessions require the sessions table. Run migrations if switching drivers:
php artisan migrate
SESSION_LIFETIME
integer
default:"120"
Session lifetime in minutes (2 hours by default).
# 2 hours
SESSION_LIFETIME=120

# 24 hours
SESSION_LIFETIME=1440
SESSION_ENCRYPT
boolean
default:"false"
Whether to encrypt session data.
Enable for sensitive applications, but increases overhead.

Queue Configuration

.env
QUEUE_CONNECTION=database
QUEUE_CONNECTION
string
default:"database"
Queue driver for background jobs:
  • sync - Process immediately (no queue)
  • database - Database-backed queue
  • redis - Redis queue (recommended for production)
  • sqs - Amazon SQS
# Development
QUEUE_CONNECTION=database

# Production
QUEUE_CONNECTION=redis
Queue workers must be running to process jobs:
php artisan queue:work

Cache Configuration

.env
CACHE_STORE=database
# CACHE_PREFIX=
CACHE_STORE
string
default:"database"
Cache driver for application caching:
  • file - File-based cache
  • database - Database cache
  • redis - Redis cache (recommended)
  • memcached - Memcached cache
  • array - Array cache (testing only)
# Development
CACHE_STORE=database

# Production with Redis
CACHE_STORE=redis
CACHE_PREFIX
string
Prefix for cache keys to avoid collisions when sharing cache storage.
CACHE_PREFIX=mediastream_

File Storage

.env
FILESYSTEM_DISK=local
BROADCAST_CONNECTION=log
FILESYSTEM_DISK
string
default:"local"
Default filesystem disk:
  • local - Local storage in storage/app
  • public - Public storage in storage/app/public
  • s3 - Amazon S3
# Local development
FILESYSTEM_DISK=local

# Production with S3
FILESYSTEM_DISK=s3

Amazon S3 Configuration

For cloud storage, configure AWS S3:
.env
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=
AWS_USE_PATH_STYLE_ENDPOINT=false
1

Create S3 bucket

Create a bucket in AWS S3 console.
2

Generate access keys

Create IAM credentials with S3 access.
3

Configure environment

.env
FILESYSTEM_DISK=s3
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=your-bucket-name

Logging Configuration

.env
LOG_CHANNEL=stack
LOG_STACK=single
LOG_DEPRECATIONS_CHANNEL=null
LOG_LEVEL=debug
LOG_CHANNEL
string
default:"stack"
Logging channel:
  • stack - Multiple channels
  • single - Single log file
  • daily - Daily rotated logs
  • stderr - Standard error output
  • syslog - System log
LOG_LEVEL
string
default:"debug"
Minimum log level to record:
  • debug - All messages
  • info - Informational and above
  • warning - Warnings and errors
  • error - Errors only
  • critical - Critical errors only
# Development
LOG_LEVEL=debug

# Production
LOG_LEVEL=warning

Mail Configuration

.env
MAIL_MAILER=log
MAIL_SCHEME=null
MAIL_HOST=127.0.0.1
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
In development, emails are logged instead of sent:
.env
MAIL_MAILER=log
View emails in:
tail -f storage/logs/laravel.log

Redis Configuration

.env
REDIS_CLIENT=phpredis
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379
REDIS_CLIENT
string
default:"phpredis"
Redis client library:
  • phpredis - PHP extension (faster)
  • predis - Pure PHP client
Redis is optional but recommended for:
  • Caching
  • Queue management
  • Session storage
  • Real-time features

Memcached Configuration

.env
MEMCACHED_HOST=127.0.0.1
MEMCACHED_HOST
string
default:"127.0.0.1"
Memcached server hostname.

Frontend Configuration

Vite Environment Variables

.env
VITE_APP_NAME="${APP_NAME}"
All VITE_* variables are accessible in frontend code:
// resources/js/app.ts
const appName = import.meta.env.VITE_APP_NAME || 'Laravel';
Changes to .env variables require restarting the Vite dev server:
npm run dev

Additional Frontend Variables

Add custom variables for frontend use:
.env
VITE_API_URL="${APP_URL}/api"
VITE_PUSHER_KEY=your-pusher-key
VITE_GOOGLE_ANALYTICS_ID=G-XXXXXXXXXX

Performance Tuning

PHP Server Workers

.env
PHP_CLI_SERVER_WORKERS=4
PHP_CLI_SERVER_WORKERS
integer
default:"4"
Number of PHP workers for the built-in server.
# Development (low traffic)
PHP_CLI_SERVER_WORKERS=4

# Heavy development
PHP_CLI_SERVER_WORKERS=8
Only applies to php artisan serve. Production should use PHP-FPM or similar.

Production Checklist

Before deploying to production:
1

Environment

.env
APP_ENV=production
APP_DEBUG=false
2

Security

  • Use HTTPS (APP_URL=https://...)
  • Set strong APP_KEY
  • Secure database credentials
  • Enable session encryption if needed
3

Performance

# Use Redis for cache and queue
CACHE_STORE=redis
QUEUE_CONNECTION=redis
SESSION_DRIVER=redis
4

Mail

Configure a production mail service (SMTP, Mailgun, etc.)
5

Storage

Consider using S3 or similar for media files:
FILESYSTEM_DISK=s3
6

Optimize

# Cache configuration
php artisan config:cache

# Cache routes
php artisan route:cache

# Cache views
php artisan view:cache

# Build assets
npm run build

Configuration Caching

For better performance, cache configuration:
# Cache all config files
php artisan config:cache

# Clear cached config
php artisan config:clear
When configuration is cached, the .env file is no longer read. You must clear cache after environment changes:
php artisan config:clear

Next Steps

Series Management

Learn how to manage series, seasons, and episodes

User Authentication

Configure authentication and security features

Architecture

Understand the technical architecture

API Reference

Explore the REST API documentation

Build docs developers (and LLMs) love