Skip to content

TraceMiddleware

Captures names of executed middleware for debugging.

class TraceMiddleware implements MiddlewareInterface

ImplementsMiddlewareInterface
SourceMiddleware/TraceMiddleware.php

public function __construct(bool $emitHeader = false, string $headerName = 'X-Quiote-Trace'): mixed

ParameterTypeDescription
$emitHeaderbool
$headerNamestring

Returns mixed

MethodDescription
process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterfaceAppends this middleware’s class name to the ExecutionState trace.

public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

Appends this middleware’s class name to the ExecutionState trace.

Reuses the ExecutionState already on the request, or creates one and attaches it, and records static::class so a subclass traces under its own name. When the constructor enabled the header, the trace is re-read from the shared ExecutionState after the downstream handler returns, so entries appended by middleware further down the stack are included; non-scalar entries are rendered as their debug type.

ParameterTypeDescription
$requestServerRequestInterface
$handlerRequestHandlerInterface

Returns ResponseInterface