Laravel Lifecycle | Working of Laravel

2 min readMay 2


Laravel is a powerful framework, and the Laravel request lifecycle is the best place to start when you want to learn more about the framework itself. An in-depth examination of the request lifecycle will aid our understanding of the Laravel structure.

  1. All requests into your application are directed from the user to Webserver through the public/index.php script. When using Apache, the .htaccess file that ships with Laravel handles the passing of all requests to index.php.
  2. Then it retrieves an instance of the Laravel application frombootstrap/app.php script. Laravel itself creates an instance of the application, which is the initial/first step.
  3. After that, The incoming request is sent to either the HTTP kernel or the console kernel, depending on the type of request that is entering the application . These two kernels serve as the central location that all requests flow through. HTTP kernel, which is placed in app/Http/Kernel.php. It just receives a Request and returns a Response. Bootstrappers are defined by the Kernel class, which configures error handling, configures logging, detects environments and other tasks to be done before the request is handled. HTTP Kernel will define the list of middleware that is passed through before being handled by the application.
  4. The most important concept to grasp when learning about Laravel’s bootstrap process is Service Providers. You can find a list of service providers by opening your app/config/app.php configuration file and finding the providers array. These providers serve as the primary bootstrapping mechanism for Laravel. But, before we dig into service providers, let's go back to index.php. After a request enters your index.php file, the bootstrap/start.php file will be loaded. This file creates the new Laravel Application object, which also serves as an IoC container.
  5. Now request will be dispatched by the Router and it will end up with the views as shown below:
  6. Router will direct the HTTP Request to a Controller or return a view or responses directly by omitting the controller. These routes will be placed in app/routes.php.
  7. Controller app/controllers/ performs specific actions and sends data to a View.
  8. View app/views/ formats the data appropriately, providing the HTTP Response.




Software Engineer | Laravel | React | Vue js | php, Python | AWS

Recommended from Medium