Laravel theorytheory 0/50 · 0%
Fundamentals · easy

6. Middleware

Filtering HTTP requests.

Middleware provide a mechanism for filtering HTTP requests entering the application, such as authentication checks or CORS handling. They are registered in bootstrap/app.php (Laravel 11+) and can be applied globally, to route groups, or individually. Middleware's handle() method receives the request and a $next closure to pass control forward.

Check your understanding

  1. 1. What does calling $next($request) do inside middleware?

  2. 2. Where is middleware registered in Laravel 11?