Documentation Index
Fetch the complete documentation index at: https://kawax.biz/llms.txt
Use this file to discover all available pages before exploring further.
Introduction
All of the configuration files for the Laravel framework are stored in theconfig/ directory. Each option is documented, so feel free to look through the files and get familiar with the options available to you.
These configuration files allow you to configure things like your database connection information, your mail server information, as well as various other core configuration values such as your application URL and encryption key.
The about command
Laravel can display an overview of your application’s configuration, drivers, and environment via the about Artisan command:
--only option:
config:show command:
Environment configuration (.env)
It is often helpful to have different configuration values based on the environment where the application is running. For example, you may wish to use a different cache driver locally than you do on your production server. Laravel uses the DotEnv PHP library for this. A fresh Laravel installation includes a.env.example file in the root directory that defines many common environment variables. During installation, this file is automatically copied to .env.
If you are developing with a team, keep the
.env.example file updated with placeholder values. This lets other developers clearly see which environment variables are needed to run your application.Environment file security
However, Laravel allows you to encrypt your environment file using built-in environment encryption. Encrypted environment files can be safely stored in source control.Additional environment files
Before loading environment variables, Laravel checks whether anAPP_ENV variable has been externally provided or whether the --env CLI argument has been specified. If so, Laravel loads .env.[APP_ENV] if it exists; otherwise it falls back to the default .env file.
Environment variable types
All variables in.env files are parsed as strings. Some reserved values allow env() to return a wider range of types:
.env value | env() return value |
|---|---|
true | (bool) true |
(true) | (bool) true |
false | (bool) false |
(false) | (bool) false |
empty | (string) '' |
(empty) | (string) '' |
null | (null) null |
(null) | (null) null |
Retrieving environment variables
All variables in your.env file are loaded into the $_ENV PHP super-global when your application receives a request. Use the env function to retrieve them inside configuration files:
Determining the current environment
The current environment is determined by theAPP_ENV variable in your .env file. Access it via the App facade’s environment method:
Encrypting environment files
To encrypt your environment file so it can safely be committed to source control:.env and writes the result to .env.encrypted. The decryption key is shown in the command output — store it in a secure password manager.
To decrypt the file:
Accessing configuration values
Use theConfig facade or the global config function to access configuration values from anywhere in your application. Values are accessed using “dot” syntax that combines the file name and the option name:
Config::set or pass an array to config:
Configuration caching
To speed up your application, cache all configuration files into a single file using theconfig:cache Artisan command:
.env file is not loaded during requests or Artisan commands. Therefore the env function only returns external, system-level environment variables.
To clear the cached configuration:
Publishing configuration files
Most of Laravel’s configuration files are already published in your application’sconfig directory. However, some files like cors.php and view.php are not published by default. Publish them with:
Debug mode
Thedebug option in config/app.php determines how much error information is displayed to the user. By default, it respects the APP_DEBUG environment variable in your .env file.
Maintenance mode
When your application is in maintenance mode, a custom view is displayed for all requests. This makes it easy to “disable” your application while updating or performing maintenance.Enabling maintenance mode
--refresh to instruct the browser to automatically refresh after a specified number of seconds:
--retry to set the Retry-After HTTP header value:
Bypassing maintenance mode
Allow specific users to bypass maintenance mode using a secret token:--with-secret:
Maintenance mode on multiple servers
By default, Laravel uses a file-based system to determine maintenance mode status. For multi-server deployments, use the cache-based approach instead:Pre-rendering the maintenance mode view
To avoid errors for users who access the application while dependencies are updating during deployment, pre-render the maintenance view:Disabling maintenance mode
Customize the default maintenance mode template by creating
resources/views/errors/503.blade.php.Next steps
Routing
Learn how to define routes and connect URLs to your application logic.