Terminable
Terminable
Optional middleware lifecycle hook for post-response cleanup.
interface TerminableA plain Middleware only gets to act before $next($request) is called and immediately after it returns — but views/templates render lazily, so the response body isn't actually built yet at that point. Middleware that needs to release or reset per-request state only once rendering has genuinely finished (e.g. an auth adapter's in-memory session state, so it doesn't leak into the next request on a long-lived worker) should implement this interface in addition to Middleware.
shutdown() is invoked once per request, for every middleware that actually ran (i.e. was not skipped via only()/except()), after the response has been fully written. If the request pipeline threw before a response could be produced, $response is null and shutdown() runs immediately rather than waiting on output that will never happen.
Methods
shutdown
Called once this middleware's part of the request is truly finished.
public shutdown(Request $request, ?Response $response): voidReturns: void
Parameters
| Parameter | Type | Description |
|---|---|---|
$request | Hazaar\Application\Request | |
$response | Hazaar\Controller\Response |
Generated by Hazaar API Doc Generator on Thu, 22 Oct 2026 05:05:29 +0000