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:
- The user sends a request from the browser.
-
The request enters through
public/index.php. -
Laravel bootstraps the application using
bootstrap/app.php. - Middleware, exception handling, and routing are configured through the application builder.
-
Laravel matches the incoming request to a route defined in
routes/web.phporroutes/api.php. - The matched route executes a closure or controller action.
- The controller interacts with models and the database if necessary.
- Laravel generates a response, such as a Blade view, JSON response, or redirect.
- 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.