The Entry Point: public/index.php
Every HTTP request entering a modern Laravel application starts at public/index.php. This tiny file acts as the front controller. It performs three critical operations:
- Loads Composer's auto-generated autoloader.
- Retrieves an instance of the Laravel application kernel from
bootstrap/app.php. - Handles the incoming HTTP request and sends the prepared response back to the client browser.
HTTP Request
│
▼
public/index.php
│
▼
bootstrap/app.php (Service Container Setup)
│
▼
HTTP Kernel & Global Middleware
│
▼
Route Matching & Route Middleware
│
▼
Controller / Action / Closure
│
▼
HTTP Response returned through Middleware pipelineService Container Bootstrapping
Before your route or controller runs, Laravel bootstraps core services registered across service providers. These configure database connections, encryption, session stores, view engines, and logging.
Middleware Pipeline
Laravel pipes the request through an onion-style series of middleware (e.g. EncryptCookies, VerifyCsrfToken, SubstituteBindings). If any middleware halts the pipeline or redirects, subsequent layers and the target controller never execute.
Response Delivery
Once the controller returns an Inertia response, JSON payload, or RedirectResponse, the response travels backward through the middleware pipeline (allowing headers or cookies to be attached) before being dispatched over the wire via FastCGI or PHP-FPM.