DebugRouteMiddleware
API reference › Yii3 Debug › Middleware › DebugRouteMiddleware
Serves the debugger endpoints under the configured route prefix and passes every other request through.
Register it before RequestCaptureMiddleware, so a debugger page is answered before the application pipeline
runs.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
__construct() | Creates debugger-route middleware with IP restrictions and optional deferred-capture finalization. | DebugRouteMiddleware |
process() | Serves a request targeting the debugger itself, and hands every other request to the next handler untouched. | DebugRouteMiddleware |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(Yiisoft\NetworkUtilities\IpRanges $allowedIpRanges, Yii3\Debug\Web\DebugRequestHandler $debugRequestHandler, Yii3\Debug\Capture\DeferredCapture|null $deferredCapture, Yii3\Debug\Middleware\ToolbarOptions $options)Creates debugger-route middleware with IP restrictions and optional deferred-capture finalization.
Parameters
| Parameter | Type | Description |
|---|---|---|
$allowedIpRanges | Yiisoft\ | Ranges allowed to reach the debugger. |
$debugRequestHandler | Yii3\ | Handler serving the debugger endpoints. |
$deferredCapture | Yii3\| | Holder of a capture still pending from an earlier request, or null when captures are finalized inside the pipeline. |
$options | ToolbarOptions | Settings carrying the route prefix. |
process()
Section titled “process() ”public function process(Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Server\RequestHandlerInterface $handler): Psr\Http\Message\ResponseInterfaceServes a request targeting the debugger itself, and hands every other request to the next handler untouched.
A capture still pending from an earlier request is written before anything else, debugger pages and requests
from a disallowed address included: a worker that never dispatched the shutdown event stops the collectors
before serving them, so their activity stays out of that capture, and the capture reaches history at once. A
failing finalization propagates from the request that triggered it. RequestCaptureMiddleware applies the
same rule, so the guarantee holds whichever of the two runs first.
Parameters
| Parameter | Type | Description |
|---|---|---|
$request | Psr\ | Request reaching the middleware. |
$handler | Psr\ | Next handler in the middleware stack. |
Returns
Psr\Http\Message\ResponseInterface: Debugger response, an empty 403 Forbidden for a disallowed client, or the application response for any other path.
Throws
Throwable: when the pending capture, the debugger endpoint, or the request handler fails.