Recall & Review
beginner
What is global middleware in Laravel?
Global middleware runs on every HTTP request to your application. It applies to all routes automatically without needing to be assigned individually.
Click to reveal answer
beginner
Where do you register global middleware in a Laravel app?
You register global middleware in the
app/Http/Kernel.php file inside the $middleware array.Click to reveal answer
intermediate
How does global middleware differ from route middleware?
Global middleware runs on every request automatically. Route middleware runs only on routes or groups where you assign it explicitly.
Click to reveal answer
beginner
Give an example of a common global middleware in Laravel.
The
CheckForMaintenanceMode middleware is often global. It checks if the app is in maintenance mode and blocks requests accordingly.Click to reveal answer
intermediate
Why use global middleware instead of route middleware?
Use global middleware for tasks that must happen on every request, like security checks or trimming input. It ensures consistency without repeating assignments.
Click to reveal answer
Where do you add global middleware in Laravel?
✗ Incorrect
Global middleware is registered in the $middleware array inside app/Http/Kernel.php.
What happens if you add middleware to the $middleware array?
✗ Incorrect
Middleware in the $middleware array runs globally on every HTTP request.
Which middleware type requires manual assignment to routes?
✗ Incorrect
Route middleware must be assigned to routes or route groups explicitly.
Why might you avoid putting heavy tasks in global middleware?
✗ Incorrect
Global middleware runs on every request, so heavy tasks can slow down all requests.
Which of these is a typical use for global middleware?
✗ Incorrect
Checking maintenance mode is a common global middleware task because it applies to all requests.
Explain what global middleware is in Laravel and how it is registered.
Think about middleware that always runs no matter the route.
You got /3 concepts.
Describe the difference between global middleware and route middleware in Laravel.
Consider when each middleware type runs during a request.
You got /4 concepts.