Laravel Request Lifecycle

Laravel Request Lifecycle

How does Laravel handle a request? What we usually see is that a route from web.php goes to the controller and then a response is received. But the whole journey of the request may not be clear to many. So let's take a look at the Laravel Lifecycle.

In case of request, the journey starts from the web server (Apache / EngineX). And from there the request goes directly to the public / index.php file. In other words, the journey of Laravel Life cycle starts from here. With the help of .htaccess file, all kinds of requests are sent to index.php.

The first important function of index.php is to record all the files inside the vendor generated from the composer. Through which we can use the classes inside the vendor in our project.

In the next step, index.php receives an instance of Laravel application. The instance returned from the bootstrap / app.php file. If we go to this file, we will see that first an instance of the Application class has been created and the base path of the application has been passed to its constructor. And in the next step 3, the class has been bound with the whole application through singleton. And that is:

1. Illuminate \ Contracts \ Http \ Kernel which is bound to App \ Http \ Kernel :: class with this class. That means Illuminate \ Contracts \ Http \ Kernel will create the instance of App \ Http \ Kernel :: class for this interface. And its job is to handle all requests from Http.

2. Illuminate \ Contracts \ Console \ Kernel which is bound to App \ Console \ Kernel :: class with this class. And its job is to handle all requests from the CLI - command-line interface.

3. Illuminate \ Contracts \ Debug \ ExceptionHandler :: class which has been bound to App \ Exceptions \ Handler :: class with this class. And this class handles all the exceptions of the project.


      পস প্রিন্টার এর সকল সমস্যার সমাধান


And once these bindings are finished, the instance of the application returns to index.php.

The journey is not over yet, there is still a long way to go ..... (Collected)

You Also Like That