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().
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners