Laravel Application Configuration

The configuration of the Laravel application deals through the 'config' subdirectory, which holds the entire configuration file related to your Laravel project. This subdirectory keeps files like a database, mailing, services, and session-based configuration files with an extension of .config. The configuration of the Laravel project permits you to define configuration per-environment. In this tutorial, you will learn about the different configurations and how the basic setup is done in Laravel.

Configuring the Basic in Laravel Project

If you are new to Laravel, then you should know that you have the provision to create configuration files for the Laravel application. After installing Laravel, you need to perform the permission writing for your storage directory along with the bootstrap/cache.

Next, you have to do is, generating the application key for session securing and encrypted data keys also. 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.

Configuring the Environment

Laravel allows us to run an application for diverse environments like testing, production, etc. For configuring your application's environment, you will need the .env file, which is in the root directory of the project. When you install composer for Laravel, then this file gets generated or created automatically by the composer itself, but if you don't install, then have to rename the specific file with the name .env.example to .env only.

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 moreover, Laravel also allowed us to use the default one as well.

Maintenance Modes

Websites are regularly modified. As s a developer for this, you have to put your site in maintenance mode. In this advanced framework, it becomes easier to do that by using two artisan commands. Let's see how to use the commands:

For starting your project maintenance approach, the following command is required:

php artisan down

After changing the required stuff, when it is time to re-run your project, the following command is needed:

php artisan up

Scroll Back to Top