RequestCollector
API reference › Debug › collectors › RequestCollector
Captures the HTTP request and response state for the Request panel.
Properties
Section titled “Properties”| Property | Type | Description | Defined by |
|---|---|---|---|
$censoredVariableNames | array<int, | Variable names whose values should be replaced with $censorString in the captured snapshot. Default: []. | RequestCollector |
$censorString | string | Replacement value emitted for variables listed in $censoredVariableNames. Default: '****'. | RequestCollector |
$displayVars | array<int, | PHP predefined variables that the collector may surface. Default: ['_COOKIE',. | RequestCollector |
$module | yii\| | Debug module supplying the log target and sibling collectors, assigned by the module on registration. Default: null. | Collector |
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
capture() final | Encodes the typed snapshot built by the subclass into the payload persisted for the panel. | Collector |
id() | Returns the stable ID pairing this collector with the Request panel. | RequestCollector |
instrument() | Installs low-level instrumentation as soon as the module registers the collector, before the panels are built. | Collector |
shutdown() final | Deactivates the collector once, releasing any subscription created by start(). | Collector |
startup() final | Activates the collector once at the start of the request lifecycle. | Collector |
censorArray() protected | Replaces the values of any $censoredVariableNames entries with $censorString, returning the sanitized top-level data. | RequestCollector |
getFlashes() protected | Returns the active flash messages without deleting them or touching the deletion counters. | RequestCollector |
getLogMessages() protected | Returns the accumulated log messages, optionally filtered by level, category, and exclusion lists. | Collector |
getLogTarget() protected | Returns the initialized log target of the owning debug module. | Collector |
isStarted() protected | Returns whether the collector is active for the current request. | Collector |
normalizeResponseHeaders() protected | Aggregates a raw response-header list into a name → value map, merging duplicates into arrays and masking entries whose name appears in $censoredVariableNames. | RequestCollector |
snapshot() protected | Snapshots the request/response state: action, route, headers, body, status code, flash messages, and the configured superglobals. | RequestCollector |
start() protected | Hook invoked once when the collector activates; subclasses subscribe to framework events here. | Collector |
stop() protected | Hook invoked once when the collector deactivates; subclasses detach subscriptions and clear state here. | Collector |
Property details
Section titled “Property details”$displayVars
Section titled “$displayVars ”public array<int, string> $displayVars = ['_COOKIE', '_FILES', '_GET', '_POST', '_SERVER', '_SESSION']PHP predefined variables that the collector may surface.
Each variable must be accessible via $GLOBALS; otherwise it is silently skipped.
Method details
Section titled “Method details”public function id(): stringReturns the stable ID pairing this collector with the Request panel.
Returns
string: Stable collector ID.
censorArray()
Section titled “censorArray() ”protected function censorArray(array<string, mixed> $data): array<string, mixed>Replaces the values of any $censoredVariableNames entries with $censorString, returning the
sanitized top-level data.
Also masks requestBody.Raw whenever a requestBody.* key is censored, so the verbatim payload does not leak
the censored field by accident.
Parameters
| Parameter | Type | Description |
|---|---|---|
$data | array<string, | Captured request payload. |
Returns
array<string, mixed>: Sanitized payload with masked values.
getFlashes()
Section titled “getFlashes() ”protected function getFlashes(): array<int|string, mixed>Returns the active flash messages without deleting them or touching the deletion counters.
Returns
array<int|string, mixed>: Flash messages keyed by their session flash name.
normalizeResponseHeaders()
Section titled “normalizeResponseHeaders() ”protected function normalizeResponseHeaders(array<int, string> $rawHeaders): array<int|string, array<int, string>|string>Aggregates a raw response-header list into a name → value map, merging duplicates into arrays and masking entries
whose name appears in $censoredVariableNames.
Parameters
| Parameter | Type | Description |
|---|---|---|
$rawHeaders | array<int, | Header lines in Name: value form, as returned by headers_list(); bare strings without a colon are kept verbatim at int-keyed slots. |
Returns
array<int|string, array<int, string>|string>: Aggregated header map with masked values.
snapshot()
Section titled “snapshot() ”protected function snapshot(): PHPForge\Debug\Panel\Request\RequestSnapshot|nullSnapshots the request/response state: action, route, headers, body, status code, flash messages, and the configured superglobals.
Header names listed in $censoredVariableNames are emitted with $censorString instead of their real
value; the same masking is applied to top-level keys in the captured payload via censorArray().
Returns
PHPForge\Debug\Panel\Request\RequestSnapshot|null: Captured request payload; null when the collector never started.