Skip to content
PHP Ecosystem
Explore

DebugRouteMiddleware

API reference › Yii3 Debug › Middleware › DebugRouteMiddleware

final readonly classYii3\Debug\Middleware\DebugRouteMiddleware
ImplementsPsr\Http\Server\MiddlewareInterface
Sourcesrc/Middleware/DebugRouteMiddleware.php

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.

MethodDescriptionDefined 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
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

ParameterTypeDescription
$allowedIpRangesYiisoft\NetworkUtilities\IpRangesRanges allowed to reach the debugger.
$debugRequestHandlerYii3\Debug\Web\DebugRequestHandlerHandler serving the debugger endpoints.
$deferredCaptureYii3\Debug\Capture\DeferredCapture|nullHolder of a capture still pending from an earlier request, or null when captures are finalized inside the pipeline.
$optionsToolbarOptionsSettings carrying the route prefix.
public function process(Psr\Http\Message\ServerRequestInterface $request, Psr\Http\Server\RequestHandlerInterface $handler): Psr\Http\Message\ResponseInterface

Serves 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

ParameterTypeDescription
$requestPsr\Http\Message\ServerRequestInterfaceRequest reaching the middleware.
$handlerPsr\Http\Server\RequestHandlerInterfaceNext 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.