Thursday, December 19, 2019

Laravel's Bootstrapping process

I will try my best to simplify Laravel's Bootstrapping process. Some terms to understand before we focus on bootstrapping process:
Service Container - holds different components which can be used in your application
Facades - Laravel has lots of features and helpers. For example helpers regarding URL, Response, Route, Session, Request etc. These are loaded into service container. Facsdes makes it possible to access these features without going through service container, and can be accessed directly.
Middleware - is a code executed on each request. For example, setting up the session. cookie encryption etc. Middleware is required by each request.
Service Providers - are classes required by your application. These are not loaded on each request, but only when the service they provide are actually needed.
Kernel - is responsible for loading all the middleware, service providers
When a web page is requested, the request first goes to index.php. This file does very important things. First it auto-loads all the classes used in your application.
After that it sets up the laravel application i.e. laravel framework. One of the first thing laravel framework does is - it creates the service container. At this point the service container is empty.
After that framework creates kernal. Kernal loads all the middleware required by the application. One of the most important task of the kernal, there after, is to load all the service providers i.e. to load all the components into the service container.
The list of all the service providers loaded are in the config/app.php file i.e. providers array. This array defines which components are loaded into your service container.
These components can be accessed via facades. The list of all facades are also present in the config/app.php as aliases array. These facades are simply short-cuts to all the components loaded into the service container. This finishes the bootstrap process.
After all this, request is then handed over to the router i.e. routes/web.php file.

No comments:

Post a Comment

Please Comment Here!

How to backup and download Database using PHP

< ?php $mysqlUserName = 'databaseusername' ; $mysqlPassword = 'databasepassword' ; $mysqlHostNa...