RequestCollector
API reference › Yii3 Debug › Collector › RequestCollector
Captures PSR-7 request and response state in the canonical Request panel shape.
Methods
Section titled “Methods”| Method | Description | Defined 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”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
| Parameter | Type | Description |
|---|---|---|
$currentRoute | Yiisoft\ | Route matched for the request, or null when routing did not run. |
$routes | Yiisoft\ | Live route collection, or null when it cannot be resolved. |
$capturePolicy | CapturePolicy | Policy deciding which values are persisted and which are redacted. |
capture()
Section titled “capture() ”public function capture(): array<string, mixed>|nullEncodes 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.
collectRequest()
Section titled “collectRequest() ”public function collectRequest(Psr\Http\Message\ServerRequestInterface $request): voidRecords the request line, headers, body, and matched route, applying the capture policy.
Parameters
| Parameter | Type | Description |
|---|---|---|
$request | Psr\ | Request reaching the debugger middleware. |
collectResponse()
Section titled “collectResponse() ”public function collectResponse(Psr\Http\Message\ResponseInterface $response): voidRecords the response status and headers, applying the capture policy.
Parameters
| Parameter | Type | Description |
|---|---|---|
$response | Psr\ | Response produced for the captured request. |
public function id(): stringReturns the stable identifier of this collector.
Returns
string: Stable ID pairing this collector with its panel.
shutdown()
Section titled “shutdown() ”public function shutdown(): voidStops capturing and clears the data accumulated for the request.
startup()
Section titled “startup() ”public function startup(): voidStarts capturing, discarding anything left from a previous request.