Skip to content
PHP Ecosystem
Explore

RequestCollector

API reference › Yii3 Debug › Collector › RequestCollector

final classYii3\Debug\Collector\RequestCollector
ImplementsCollectorInterface, RequestObserverInterface
Sourcesrc/Collector/RequestCollector.php

Captures PSR-7 request and response state in the canonical Request panel shape.

MethodDescriptionDefined by
__construct()Creates a request collector with routing context and the capture policy.RequestCollector
capture()Encodes the captured request and response into the Request panel payload.RequestCollector
collectRequest()Records the request line, headers, body, and matched route, applying the capture policy.RequestCollector
collectResponse()Records the response status and headers, applying the capture policy.RequestCollector
id()Returns the stable identifier of this collector.RequestCollector
shutdown()Stops capturing and clears the data accumulated for the request.RequestCollector
startup()Starts capturing, discarding anything left from a previous request.RequestCollector
public function __construct(Yiisoft\Router\CurrentRoute|null $currentRoute = null, Yiisoft\Router\RouteCollectionInterface|null $routes = null, PHPForge\Debug\Capture\CapturePolicy $capturePolicy = new \PHPForge\Debug\Capture\CapturePolicy())

Creates a request collector with routing context and the capture policy.

Parameters

ParameterTypeDescription
$currentRouteYiisoft\Router\CurrentRoute|nullRoute matched for the request, or null when routing did not run.
$routesYiisoft\Router\RouteCollectionInterface|nullLive route collection, or null when it cannot be resolved.
$capturePolicyCapturePolicyPolicy deciding which values are persisted and which are redacted.
public function capture(): array<string, mixed>|null

Encodes the captured request and response into the Request panel payload.

When the handler never returned a response, because the script ended inside it through exit, dd(), or a fatal error, the response half carries the matched route and the status code PHP is about to send, without headers, since no PSR-7 response exists.

Returns

array<string, mixed>|null: Encoded Request panel payload; null when the request was not observed.

public function collectRequest(Psr\Http\Message\ServerRequestInterface $request): void

Records the request line, headers, body, and matched route, applying the capture policy.

Parameters

ParameterTypeDescription
$requestPsr\Http\Message\ServerRequestInterfaceRequest reaching the debugger middleware.
public function collectResponse(Psr\Http\Message\ResponseInterface $response): void

Records the response status and headers, applying the capture policy.

Parameters

ParameterTypeDescription
$responsePsr\Http\Message\ResponseInterfaceResponse produced for the captured request.
public function id(): string

Returns the stable identifier of this collector.

Returns

string: Stable ID pairing this collector with its panel.

public function shutdown(): void

Stops capturing and clears the data accumulated for the request.

public function startup(): void

Starts capturing, discarding anything left from a previous request.