Application Configuration Files
The config/ directory contains PHP files that define every configurable aspect of your Laravel application. Each file returns an associative array of settings: app.php (application name, timezone, locale, providers), database.php (connection details for MySQL, PostgreSQL, SQLite, SQL Server), cache.php (cache store drivers), queue.php (queue connections), mail.php (email drivers and credentials), and more. These files read from .env for environment-specific values but also contain defaults and static configuration.
Key Configuration Files
- config/app.php — Application name, environment, debug mode, timezone, locale, service providers array, and class aliases. The providers array is where Laravel discovers your service providers
- config/database.php — Database connections (mysql, pgsql, sqlite, sqlsrv), default connection, migration table name, and Redis configuration. Supports multiple simultaneous connections
- config/cache.php — Cache store configuration: file, database, Redis, Memcached, DynamoDB. Set default with CACHE_DRIVER in .env. Redis is recommended for production
- config/queue.php — Queue driver configuration: sync (immediate), database, Redis, SQS, Beanstalkd. Queue connections define how background jobs are processed
- config/mail.php — Mail driver setup: SMTP, Mailgun, Postmark, SES. Configure default sender address and name. Use Mailtrap or Mailpit for local email testing
- config/logging.php — Log channels: single file, daily rotation, Sentry, Slack, stack (multiple channels). Laravel uses Monolog under the hood
Accessing Configuration Values
// Read a config value
$appName = config('app.name'); // 'MyLaravelApp'
$dbHost = config('database.connections.mysql.host');
// With a default fallback
$timezone = config('app.timezone', 'UTC');
// Set a config value at runtime (current request only)
config(['app.debug' => false]);
// WRONG in production (returns null when config is cached):
$value = env('APP_NAME');
// CORRECT (always works):
$value = config('app.name');Tip
Tip
Practice Application Configuration Files in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.
Middleware = filters that run before/after your controller logic
Practice Task
Note
Practice Task — (1) Write a working example of Application Configuration Files from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.
Quick Quiz
Common Mistake
Warning
A common mistake with Application Configuration Files is skipping edge case testing — empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready laravel code.
Key Takeaways
- The config/ directory contains PHP files that define every configurable aspect of your Laravel application.
- config/app.php — Application name, environment, debug mode, timezone, locale, service providers array, and class aliases. The providers array is where Laravel discovers your service providers
- config/database.php — Database connections (mysql, pgsql, sqlite, sqlsrv), default connection, migration table name, and Redis configuration. Supports multiple simultaneous connections
- config/cache.php — Cache store configuration: file, database, Redis, Memcached, DynamoDB. Set default with CACHE_DRIVER in .env. Redis is recommended for production