Advertisement

Google Ad Slot: content-top

Laravel Request Lifecycle


Browser Request (http://my-app.test)
  ↓
public/index.php
  ↓
bootstrap/app.php
  ↓
Service Providers (config/*.php)
  ↓
Routes(web.php/api.php) → Middleware → Controller
  ↓
Response
  ↓
Browser


  • Every request to your Laravel app starts at public/index.php.
  • It boots the Laravel framework using bootstrap/app.php and load routes(web.php,api.php).
  • Creates the application instance. so loads service providers from config/*.php
  • Routes are defined in:
  • routes/web.php (for web requests)
  • routes/api.php (for API requests)
  • Before hitting the controller, Laravel passes the request through middleware stack.
  • If a controller or closure is matched laravel executes the method.
  • Whatever the route/controller returns (string, view(), json()) is wrapped into a Illuminate\Http\Response object.
  • The request lifecycle ends.