Request life Cycle Of Laravel

Web Developer Kaustubh
2 min readAug 9, 2022
Laravel Request Life Cycle

1]Index.php

This is entry point of all the Laravel request.

This Stage performs following important actions
a]Loads the Composer generated autoloader files.
b]Retrieves an instance of the Laravel application.

2]Kernel

After retrieving instance of laravel application incoming request in sent to the Kernel. Kernal is central location for all income request.

This Stage performs following important actions
a]Defines a list of HTTP middleware that all requests must pass through before being handled by the application.
b] loading the service providers for your application.

3]Middleware

Middleware provide a convenient mechanism for filtering or examining HTTP requests entering your application. For example, Laravel includes a middleware that verifies if the user of your application is authenticated. If the user is not authenticated, the middleware will redirect the user to the login screen

once the response travels back through the middleware, the HTTP kernel’s handle method returns the response object and giving the application a chance to modify or examine the outgoing response after that the index.php file calls the send method on the returned response.

4]Service Provider

Service providers are responsible for bootstrapping all of the framework’s various components, such as the database, queue, validation, and routing components.

All of the service providers for the application are configured in the config/app.php configuration file’s providers array.

Laravel will iterate through this list of providers and instantiate each of them. After instantiating the providers, the register method will be called on all of the providers. Then, once all of the providers have been registered, the boot method will be called on each provider. This is so service providers may depend on every container binding being registered and available by the time their boot method is executed.

This Stage performs following important actions
a] bootstrap all of the framework’s various components, such as the database, queue, validation, and routing components.

4]Router:-

Once the application has been bootstrapped and all service providers have been registered, the Request will be handed off to the router for dispatching. The router will dispatch the request to a route or controller, as well as run any route specific middleware.

5]Response:-

Once the route or controller method returns a response, the response will travel back outward through the route’s middleware, giving the application a chance to modify or examine the outgoing response.

--

--

Web Developer Kaustubh

Sr.Web developer. love to code. PHP , Javascript, Mysql, Laravel, Jquey, git, project planing,Linux