Skip to main content

Overview

Nguhöe EHR uses environment variables to configure application behavior across different environments. All configuration is managed through the .env file, which should never be committed to version control.

Getting Started

Copy the example environment file to create your configuration:
cp .env.example .env
php artisan key:generate

Application Settings

APP_NAME
string
default:"Laravel"
The name of your application. Used in emails, notifications, and UI elements.
APP_NAME="Nguhöe EHR"
APP_ENV
string
default:"local"
The application environment. Determines configuration behavior and error reporting.Options: local, staging, production
APP_ENV=production
APP_KEY
string
required
Application encryption key. Auto-generated with php artisan key:generate. Required for session and data encryption.
APP_KEY=base64:randomgeneratedkeyhere
APP_DEBUG
boolean
default:"true"
Enable detailed error messages and stack traces. Must be false in production.
APP_DEBUG=false  # Production
APP_DEBUG=true   # Development
APP_URL
string
default:"http://localhost"
The base URL of your application. Used for generating links and asset URLs.
APP_URL=https://ehr.example.com
APP_LOCALE
string
default:"en"
Default application language.
APP_LOCALE=en
APP_FALLBACK_LOCALE
string
default:"en"
Fallback language when the current language is unavailable.
APP_FALLBACK_LOCALE=en
APP_FAKER_LOCALE
string
default:"en_US"
Locale for generating fake data in development and testing.
APP_FAKER_LOCALE=en_US
APP_MAINTENANCE_DRIVER
string
default:"file"
Storage driver for maintenance mode state.Options: file, database
APP_MAINTENANCE_DRIVER=file

Security Settings

BCRYPT_ROUNDS
integer
default:"12"
Number of bcrypt hashing rounds for password encryption. Higher values increase security but require more CPU.Recommended: 12 for production
BCRYPT_ROUNDS=12

Database Configuration

DB_CONNECTION
string
default:"sqlite"
Database driver to use.Options: sqlite, mysql, mariadb, pgsql, sqlsrv
DB_CONNECTION=mysql
DB_HOST
string
default:"127.0.0.1"
Database server hostname or IP address.
DB_HOST=127.0.0.1
DB_PORT
integer
default:"3306"
Database server port.Defaults: MySQL/MariaDB: 3306, PostgreSQL: 5432, SQL Server: 1433
DB_PORT=3306
DB_DATABASE
string
default:"laravel"
Name of the database. For SQLite, this is the path to the database file.
# MySQL/PostgreSQL
DB_DATABASE=nguhoe_ehr

# SQLite
DB_DATABASE=/path/to/database/database.sqlite
DB_USERNAME
string
default:"root"
Database username for authentication.
DB_USERNAME=nguhoe_user
DB_PASSWORD
string
Database password for authentication.
DB_PASSWORD=secure_password_here

Session Configuration

SESSION_DRIVER
string
default:"database"
Session storage driver.Options: file, cookie, database, memcached, redis, arrayRecommended: database for production
SESSION_DRIVER=database
SESSION_LIFETIME
integer
default:"120"
Session lifetime in minutes. Users will be logged out after this period of inactivity.
SESSION_LIFETIME=120  # 2 hours
SESSION_ENCRYPT
boolean
default:"false"
Encrypt session data before storage. Adds security but slight performance overhead.
SESSION_ENCRYPT=false
SESSION_PATH
string
default:"/"
Cookie path for session. Usually the root path.
SESSION_PATH=/
SESSION_DOMAIN
string
Cookie domain for session. Leave null for current domain.
SESSION_DOMAIN=null

Cache Configuration

CACHE_STORE
string
default:"database"
Default cache storage driver.Options: file, database, memcached, redis, array
CACHE_STORE=database
CACHE_PREFIX
string
Prefix for cache keys to avoid collisions with other applications.
CACHE_PREFIX=nguhoe_cache_

Queue Configuration

QUEUE_CONNECTION
string
default:"database"
Queue driver for background job processing.Options: sync, database, redis, sqs, beanstalkdRecommended: database for production, sync for local development
QUEUE_CONNECTION=database

Mail Configuration

MAIL_MAILER
string
default:"log"
Mail transport driver.Options: smtp, sendmail, mailgun, ses, postmark, log
MAIL_MAILER=smtp
MAIL_HOST
string
default:"127.0.0.1"
SMTP server hostname.
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT
integer
default:"2525"
SMTP server port.Common ports: 25, 465 (SSL), 587 (TLS), 2525
MAIL_PORT=587
MAIL_USERNAME
string
SMTP authentication username.
MAIL_USERNAME=your-smtp-username
MAIL_PASSWORD
string
SMTP authentication password.
MAIL_PASSWORD=your-smtp-password
MAIL_FROM_ADDRESS
string
Default sender email address.
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME
string
default:"${APP_NAME}"
Default sender name.
MAIL_FROM_NAME="Nguhöe EHR"
MAIL_SCHEME
string
Mail encryption protocol.Options: tls, ssl, null
MAIL_SCHEME=tls

Redis Configuration

REDIS_CLIENT
string
default:"phpredis"
Redis client library.Options: phpredis, predis
REDIS_CLIENT=phpredis
REDIS_HOST
string
default:"127.0.0.1"
Redis server hostname.
REDIS_HOST=127.0.0.1
REDIS_PASSWORD
string
default:"null"
Redis authentication password.
REDIS_PASSWORD=your_redis_password
REDIS_PORT
integer
default:"6379"
Redis server port.
REDIS_PORT=6379

Logging Configuration

LOG_CHANNEL
string
default:"stack"
Default logging channel.Options: stack, single, daily, slack, syslog, errorlog
LOG_CHANNEL=stack
LOG_STACK
string
default:"single"
Channels to include in the stack.
LOG_STACK=single
LOG_LEVEL
string
default:"debug"
Minimum log level to record.Options: debug, info, notice, warning, error, critical, alert, emergencyRecommended: error for production, debug for development
LOG_LEVEL=error  # Production
LOG_LEVEL=debug  # Development
LOG_DEPRECATIONS_CHANNEL
string
default:"null"
Channel for logging deprecation warnings.
LOG_DEPRECATIONS_CHANNEL=null

File Storage Configuration

FILESYSTEM_DISK
string
default:"local"
Default filesystem disk for file storage.Options: local, public, s3
FILESYSTEM_DISK=local

Broadcasting Configuration

BROADCAST_CONNECTION
string
default:"log"
Broadcasting driver for real-time events.Options: log, pusher, ably, redis, null
BROADCAST_CONNECTION=log

AWS Configuration

AWS_ACCESS_KEY_ID
string
AWS access key ID for S3, SES, or other AWS services.
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY
string
AWS secret access key.
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_DEFAULT_REGION
string
default:"us-east-1"
AWS region for services.
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET
string
S3 bucket name for file storage.
AWS_BUCKET=nguhoe-ehr-files

Vite Configuration

VITE_APP_NAME
string
default:"${APP_NAME}"
Application name exposed to the frontend build process.
VITE_APP_NAME="${APP_NAME}"

Environment-Specific Configurations

Local Development

APP_NAME="Nguhöe EHR"
APP_ENV=local
APP_DEBUG=true
APP_URL=http://localhost:8000

DB_CONNECTION=sqlite
DB_DATABASE=/path/to/database/database.sqlite

SESSION_DRIVER=file
CACHE_STORE=file
QUEUE_CONNECTION=sync

MAIL_MAILER=log
LOG_LEVEL=debug

Staging Environment

APP_NAME="Nguhöe EHR - Staging"
APP_ENV=staging
APP_DEBUG=true
APP_URL=https://staging.ehr.example.com

DB_CONNECTION=mysql
DB_HOST=staging-db.example.com
DB_PORT=3306
DB_DATABASE=nguhoe_staging
DB_USERNAME=staging_user
DB_PASSWORD=secure_password

SESSION_DRIVER=database
SESSION_LIFETIME=120

CACHE_STORE=database
QUEUE_CONNECTION=database

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525

LOG_LEVEL=debug

Production Environment

APP_NAME="Nguhöe EHR"
APP_ENV=production
APP_DEBUG=false
APP_URL=https://ehr.example.com

DB_CONNECTION=mysql
DB_HOST=production-db.example.com
DB_PORT=3306
DB_DATABASE=nguhoe_production
DB_USERNAME=production_user
DB_PASSWORD=very_secure_password

SESSION_DRIVER=database
SESSION_LIFETIME=120
SESSION_ENCRYPT=false

CACHE_STORE=redis
REDIS_HOST=redis.example.com
REDIS_PASSWORD=redis_password
REDIS_PORT=6379

QUEUE_CONNECTION=database

MAIL_MAILER=smtp
MAIL_HOST=smtp.sendgrid.net
MAIL_PORT=587
MAIL_USERNAME=apikey
MAIL_PASSWORD=your_sendgrid_api_key
MAIL_FROM_ADDRESS=[email protected]
MAIL_FROM_NAME="Nguhöe EHR"

LOG_LEVEL=error
LOG_CHANNEL=daily

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=nguhoe-ehr-production

Security Considerations

Never commit your .env file to version control. It contains sensitive credentials and secrets.

Production Security Checklist

  • Set APP_DEBUG=false to prevent information leakage
  • Use strong, unique values for APP_KEY
  • Enable HTTPS and set APP_URL to use https://
  • Use BCRYPT_ROUNDS=12 or higher for password hashing
  • Set appropriate SESSION_LIFETIME based on your security requirements
  • Use SESSION_ENCRYPT=true for sensitive applications
  • Restrict database user permissions to only required operations
  • Use strong database passwords
  • Enable Redis authentication with REDIS_PASSWORD
  • Set LOG_LEVEL=error to reduce disk usage
  • Review and remove unused AWS credentials
  • Use environment-specific mail settings to prevent accidental emails

File Permissions

Ensure proper file permissions for the .env file:
chmod 600 .env
chown www-data:www-data .env

Environment Variables in Code

Never use env() helper directly in your application code. Always access environment variables through configuration files using config().
// ❌ Bad - Direct env() usage
$appName = env('APP_NAME');

// ✅ Good - Use config()
$appName = config('app.name');

Troubleshooting

Configuration Cache

In production, Laravel caches configuration for performance. After changing .env, clear the cache:
php artisan config:clear
php artisan config:cache

Missing APP_KEY Error

If you see “No application encryption key has been specified”:
php artisan key:generate

Database Connection Issues

Verify database credentials and connectivity:
php artisan tinker
>>> DB::connection()->getPdo();

Mail Testing

Test mail configuration:
php artisan tinker
>>> Mail::raw('Test email', function($msg) { $msg->to('[email protected]')->subject('Test'); });

Build docs developers (and LLMs) love