Skip to content
PHP Ecosystem
Explore

ProfilingCollector

API reference › Yii3 Debug › Collector › ProfilingCollector

final classYii3\Debug\Collector\ProfilingCollector
ImplementsCollectorInterface
Sourcesrc/Collector/ProfilingCollector.php

Captures request metrics and completed Yii profiler spans in the canonical Profiling panel payload.

MethodDescriptionDefined by
__construct()Creates a profiling collector for live and already flushed spans.ProfilingCollector
capture()Encodes the captured spans into the Profiling panel payload.ProfilingCollector
collectRequest()Records the request start when the middleware did not already supply it.ProfilingCollector
collectRequestStart()Uses the request start already resolved by the middleware so summary and profiler timing share one origin.ProfilingCollector
id()Returns the stable identifier of this collector.ProfilingCollector
shutdown()Stops capturing and clears the spans accumulated for the request.ProfilingCollector
startup()Starts capturing and resets the cursor into the profiler message list.ProfilingCollector
public function __construct(Yiisoft\Profiler\ProfilerInterface|null $profiler = null, Yii3\Debug\Profiling\DebugProfilerTarget|null $target = null)

Creates a profiling collector for live and already flushed spans.

Parameters

ParameterTypeDescription
$profilerYiisoft\Profiler\ProfilerInterface|nullApplication profiler supplying the spans, or null when none is configured.
$targetYii3\Debug\Profiling\DebugProfilerTarget|nullTarget keeping the spans the profiler already flushed, or null when the profiler dispatches to no debugger target.
public function capture(): array<string, mixed>|null

Encodes the captured spans into the Profiling panel payload.

Returns

array<string, mixed>|null: Encoded Profiling panel payload; null when the collector never started.

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

Records the request start when the middleware did not already supply it.

Parameters

ParameterTypeDescription
$requestPsr\Http\Message\ServerRequestInterfaceRequest reaching the debugger middleware.
public function collectRequestStart(float $start): void

Uses the request start already resolved by the middleware so summary and profiler timing share one origin.

Parameters

ParameterTypeDescription
$startfloatRequest start, in seconds.
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 spans accumulated for the request.

public function startup(): void

Starts capturing and resets the cursor into the profiler message list.