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.
← Laravel theorytheory 0/50 · 0%
Fundamentals · easy
6. Middleware
Filtering HTTP requests.
Check your understanding
1. What does calling $next($request) do inside middleware?
2. Where is middleware registered in Laravel 11?