Laravel - Configuration
basic design documents of Laravel are incorporated into the config directory.
Environment factors are those which give a rundown of web administrations to your web application. All the earth factors are announced in the .env document which incorporates the parameters required for introducing the configuration.
By default, the .env document incorporates following parameters −
APP_ENV = neighborhood APP_DEBUG = genuine APP_KEY = base64:ZPt2wmKE/X4eEhrzJU6XX4R93rCwYG8E2f8QUA7kGK8 = APP_URL = http://localhost DB_CONNECTION = mysql DB_HOST = 127.0.0.1 DB_PORT = 3306 DB_DATABASE = property DB_USERNAME = property DB_PASSWORD = mystery CACHE_DRIVER = record SESSION_DRIVER = record QUEUE_DRIVER = adjust REDIS_HOST = 127.0.0.1 REDIS_PASSWORD = invalid REDIS_PORT = 6379 MAIL_DRIVER = smtp MAIL_HOST = mailtrap.ioMAIL_PORT = 2525 MAIL_USERNAME = invalid MAIL_PASSWORD = invalid MAIL_ENCRYPTION = invalid
While working with fundamental arrangement documents of Laravel, the accompanying focuses are to be noted −
The .env document ought not be focused on the application source control, since every engineer or client has some predefined condition arrangement for the web application.
For reinforcement alternatives, the improvement group ought to incorporate the .env.example record, which ought to contain the default configuration.
Retrieval of Environment Variables
All nature factors announced in the .env document can be gotten to by env-helper capacities which will call the separate parameter. These factors are additionally recorded into $_ENV worldwide variable at whatever point application gets a demand from the client end. You can get to nature variable as appeared beneath −
'env' => env('APP_ENV', 'creation'),
env-helper capacities are brought in the app.php record incorporated into the config envelope. The above given model is requiring the essential neighborhood parameter.
Accessing Configuration Values
You can without much of a stretch access the arrangement esteems anyplace in the application utilizing the worldwide config partner work. On the off chance that if the arrangement esteems are not introduced, default esteems are returned.
For model, to set the default time zone, the accompanying code is utilized −
config(['app.timezone' => 'Asia/Kolkata']);
Caching of Configuration
To increment the execution and to help the web application, it is imperative to reserve all the arrangement esteems. The order for reserving the setup esteems is −
The following screen capture indicates storing in an efficient methodology −
Sometimes you may need to refresh some setup esteems or perform upkeep on your site. In such cases, keeping it in support mode, makes it less demanding for you. Such web applications which are kept in support mode, toss a special case to be specific MaintenanceModeException with a status code of 503.
You can empower the upkeep mode on your Laravel web application utilizing the accompanying direction −
php craftsman down