Understanding Laravel’s request cycle

To understand Laravel request cycle, we have to understand following six stages:

Understanding Laravel’s request cycle
Understanding Laravel’s request cycle

index.php:

Firstly the user will send or trigger a HTTP request to web server. This request will be received by the web server who will directly load it to index.php so that the rest of framework will be auto loaded.

Auto load:

In the second step, the Laravel index.php will auto load the files which are directly generated by the composer.

Instance:

The Laravel itself create an instance. Then the index.php will retrieve the instance from the bootstrap/app.php. then the request goes to the kernel.

Kernel:

The task of the kernel is to receive the above request and generate the response according to the request. but the kernel is of two types:

The first one is HTTP kernel and the second is console kernel.

Now the question arises which type of kernel will receive the request. It is just upon the type of the request like error handling or detecting environment. These types of request are received by the http kernel and generate the response according to the request.




Service provider:

The next step is to create service provider. Service provider are those which are required for the bootstrap action. Then all the service provider will be registered. Once the service provider has been boot, the request will go to the router.

Router:

Router will send this request to the controller which provides the view back to the router. Router will detect the content of the view file and give back to the web server. If the user request does not decides what information the user actually want and send a random request then the router take the request object as well as the route object.

At last the http response is generated and send to the user as a view.

    Conclusion:

    At last if you have understood the request cycle of the Laravel, then you will have more knowledge to design new application and as well as more confidence. It also provides you the skill so that the developer can fix the error easily. You can also detect the unexpected errors during the designing of the application.

Leave a Reply

Your email address will not be published. Required fields are marked *