Laravel Configuration


Basic Configuration

After the installation of Laravel, you will be required to set an application key to a random string. This step is not required if you have installed Laravel with the help of the Composer. In such a case, the application key has already been set with the help of the command ‘key:generate’. This key has to be 32 characters long. For setting this application key, you can use the configuration file under the name: ‘app.php’. If this key is not set then your data and all the user sessions will not stay protected.

Or you can just follow the basic steps given below.

* You can now directly begin by setting the write permission for the directory storage. You also need to set the write permission for the bootstrap/cache.

* After this step, generate an application key to protect your user sessions and the already encrypted data. Check the root directory whether it contains the .env file. If the root directory is absent of .env file, then simply rename the .env.example file to .env file. Now, generate the application key by using the following command.

Also Read: Laravel Application Structure

This step is not required if you have installed Laravel with the help of tlaravel>php artisan key:generate

The application key has been generated and it can be found in the .env file.

* The updation of time zone, locale, and a few other attributes can be done in the config/app.php file.

Environmental Configuration

The MVC framework allows you to run your application on several different environments which ranges from testing to production. You can change the environment of your application by opening the .env file. If you have installed the Laravel Composer then the file automatically been updated.

In the .env file, the APP_ENV is set as local. You can change it to production or testing, according to your environment requirement.

Database Configuration

You can also configure the associated database of your application. Go to config directory and look for database.php. You can add the configuration parameters in the file for different databases

Application Naming

If you want to rename the app directory then type in the below command.

laravel> php artisan app:name <new-name-for-application>

You can rename the app directory by putting in your desired name in the <new-name-for-application> field.

Maintenance Mode

Every website a regular maintenance. For this, you need to change the mode to maintenance. You can start and stop the maintenance of your website by the help of the following commands.

To start maintenance mode: laravel> php artisan down

To stop maintenance mode: laravel> php artisan up