If you are new to Laravel, you should know that you can create a configuration file for the Laravel application. And after installing the Laravel, you need to perform the permission writing for your storage directory along with the bootstrap/cache.
Next, you have to generate the application key for session securing and encrypted data keys. In case the root directory doesn’t have the .env file, in that case, you will have to rename the file .env.example to .env and run the command mentioned below where you’ve installed the Laravel:
php artisan key: generate
You can see in the .env file the newly generated key. Moreover, it is also possible to configure the time zone as well as a locale in the config/app.php file of your project.
Environment variables provide a list of web services to your web application. All the environment variables are declared in the .env file which contains the parameters required for initializing the configuration.
Accessing Configuration Values
Using the global config helper function, you can easily access the configuration values anywhere in the application. In case the configuration values are not initialized, default values are returned.
For example, to set the default time zone, the following code is used −
config(['app.timezone' => 'Asia/Kolkata']);
Configuring the Database
You can configure the database for your application using the config/database.php file of your project. Setting the configuration constraint utilized by various databases can also be done, and Laravel also allowed us to use the default one.
Configuring the Cache
To increase the performance and boost the web application, it is important to cache all the configuration values. The command for caching the configuration values is −
php artisan config:cache
Sometimes you may need to update some configuration values or perform maintenance on your website. In such cases, keeping it in maintenance mode makes it easier for you. Such web applications which are kept in maintenance mode, throw an exception namely MaintenanceModeException with a status code of 503.
You can enable the maintenance mode on your Laravel web application using the following command −
php artisan down
After finishing the work on updates and other maintenance, you can disable the maintenance mode on your web application using the following command −
php artisan up