This post assumes basic familiarity with Laravel’s https://laravel.com/docs/9.x/lifecycle and https://laravel.com/docs/9.x/middleware. Before middleware can be used to authenticate users, set the app language, or limit responses based on the request.
In this post, we’ll look at a handy but less utilized type of middleware: Terminable middleware.
The illustration above, based on a graphic from https://laravelupandrunning.com/, shows where before, after, and terminable middleware are processed during the request lifecycle.
Unlike other types of middleware, terminable middleware define a terminate() method rather than handle().