MWZ

MINDWAREZONE

What is the Laravel request lifecycle?

The Laravel request lifecycle describes how a request travels through the framework from the moment a user sends it until a response is returned to the browser.

Request Lifecycle in Laravel

In Laravel 12 and 13, every request enters through public/index.php, which loads Composer's autoloader and bootstraps the application using bootstrap/app.php.

The request lifecycle is as follows:

  1. The user sends a request from the browser.
  2. The request enters through public/index.php.
  3. Laravel bootstraps the application using bootstrap/app.php.
  4. Middleware, exception handling, and routing are configured through the application builder.
  5. Laravel matches the incoming request to a route defined in routes/web.php or routes/api.php.
  6. The matched route executes a closure or controller action.
  7. The controller interacts with models and the database if necessary.
  8. Laravel generates a response, such as a Blade view, JSON response, or redirect.
  9. The response is returned to the browser.
Browser
   ↓
public/index.php
   ↓
bootstrap/app.php
   ↓
Middleware
   ↓
Routes
   ↓
Controller / Closure
   ↓
Model / Database
   ↓
Response
   ↓
Browser
            

If the interviewer asks, "What changed from older versions?", you can add:

Earlier Laravel versions used app/Http/Kernel.php to register middleware and handle HTTP requests. Laravel 11/12/13 moved this configuration into bootstrap/app.php using the Application Builder, resulting in a simpler project structure.