Course Content
Laravel Introduction
Laravel is a PHP framework that uses the MVC architecture. Laravel is a robust framework that provides easy development of PHP web applications with features like a modular packaging system with a dedicated dependency manager, access to relational databases, and other utilities for application deployment and maintenance.
0/4
Laravel Routing
Routing is one of the essential concepts in Laravel. Routing in Laravel allows you to route all your application requests to its appropriate controller. The main functionality of the routes is to route all your application requests to the appropriate controller.
0/3
Laravel Controllers
Laravel controllers are an essential feature in a Laravel framework.
0/1
Private: Laravel
About Lesson

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 Configuration

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.

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:/u0xl40fjwHmQigZdnUPtV/K8HAL5jDJTulTx8O779E=
APP_DEBUG=true
APP_URL=http://localhost

LOG_CHANNEL=stack

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=

BROADCAST_DRIVER=log
CACHE_DRIVER=file
QUEUE_CONNECTION=sync
SESSION_DRIVER=file
SESSION_LIFETIME=120

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
AWS_BUCKET=

PUSHER_APP_ID=
PUSHER_APP_KEY=
PUSHER_APP_SECRET=
PUSHER_APP_CLUSTER=mt1

MIX_PUSHER_APP_KEY="${PUSHER_APP_KEY}"
MIX_PUSHER_APP_CLUSTER="${PUSHER_APP_CLUSTER}"

 

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

 

Maintenance Mode

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