Skip to content
PHP Ecosystem
Explore

RequestCollector

API reference › Debug › collectors › RequestCollector

classyii\debug\collectors\RequestCollector
ExtendsCollector
ImplementsCollectorInterface
Sourcesrc/collectors/RequestCollector.php

Captures the HTTP request and response state for the Request panel.

PropertyTypeDescriptionDefined by
$censoredVariableNamesarray<int, string>Variable names whose values should be replaced with $censorString in the captured snapshot. Default: [].RequestCollector
$censorStringstringReplacement value emitted for variables listed in $censoredVariableNames. Default: '****'.RequestCollector
$displayVarsarray<int, string>PHP predefined variables that the collector may surface. Default: ['_COOKIE', '_FILES', '_GET', '_POST', '_SERVER', '_SESSION'].RequestCollector
$moduleyii\debug\Module|nullDebug module supplying the log target and sibling collectors, assigned by the module on registration. Default: null.Collector
MethodDescriptionDefined by
capture() finalEncodes 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() finalDeactivates the collector once, releasing any subscription created by start().Collector
startup() finalActivates the collector once at the start of the request lifecycle.Collector
censorArray() protectedReplaces the values of any $censoredVariableNames entries with $censorString, returning the sanitized top-level data.RequestCollector
getFlashes() protectedReturns the active flash messages without deleting them or touching the deletion counters.RequestCollector
getLogMessages() protectedReturns the accumulated log messages, optionally filtered by level, category, and exclusion lists.Collector
getLogTarget() protectedReturns the initialized log target of the owning debug module.Collector
isStarted() protectedReturns whether the collector is active for the current request.Collector
normalizeResponseHeaders() protectedAggregates a raw response-header list into a name → value map, merging duplicates into arrays and masking entries whose name appears in $censoredVariableNames.RequestCollector
snapshot() protectedSnapshots the request/response state: action, route, headers, body, status code, flash messages, and the configured superglobals.RequestCollector
start() protectedHook invoked once when the collector activates; subclasses subscribe to framework events here.Collector
stop() protectedHook invoked once when the collector deactivates; subclasses detach subscriptions and clear state here.Collector
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.

public function id(): string

Returns the stable ID pairing this collector with the Request panel.

Returns

string: Stable collector ID.

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

ParameterTypeDescription
$dataarray<string, mixed>Captured request payload.

Returns

array<string, mixed>: Sanitized payload with masked values.

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.

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

ParameterTypeDescription
$rawHeadersarray<int, string>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.

protected function snapshot(): PHPForge\Debug\Panel\Request\RequestSnapshot|null

Snapshots 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.