Laravel & Ecosystem (50 Qs)•Part 1: Architecture, Service Container & Request Lifecycle (1 - 10)
What is the Laravel Request Lifecycle (`public/index.php` to HTTP Kernel)?
senior LevelMost AskedCode ExampleLifecycleDocker & ContainersSystem Design
In Simple Words: The entry-to-exit journey of a Laravel request:
- All traffic enters
public/index.php. - Composer autoloader is initialized.
bootstrap/app.phpinitializes the Service Container and builds the HTTP Kernel.- The HTTP Kernel bootstraps critical providers: Error handling, Logging, Environment (
.env), Configuration files. - The request passes through the Global Middleware Pipeline (Sessions, CSRF, Cookies).
- Routing: Matches URL, resolves route-specific middleware, executes Controller action.
- Controller returns a
Response; middleware pipeline executes post-response tasks; sent back to client.
text
Laravel Request Lifecycle:
[HTTP Request] ──► [public/index.php] ──► [Service Container Boot]
│
▼
[HTTP Response] ◄── [Controller Action] ◄── [Middleware Pipeline]