Skip to content

ExecutionTimeMiddleware

Basic execution timing middleware replacing ExecutionTimeFilter.

class ExecutionTimeMiddleware implements MiddlewareInterface

ImplementsMiddlewareInterface
SourceMiddleware/ExecutionTimeMiddleware.php

public function __construct(bool $appendHtmlComment = true, ClockInterface $clock = new SystemClock(…)): mixed

ParameterTypeDescription
$appendHtmlCommentbool
$clockClockInterface

Returns mixed

MethodDescription
process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterfaceTimes the rest of the pipeline and optionally appends the duration as an HTML comment.

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

Times the rest of the pipeline and optionally appends the duration as an HTML comment.

The comment is only appended when the constructor was told to and the response is a PsrResponseAdapter whose wrapped response already carries string content — a streamed or non-string body is left alone, so the duration is silently dropped rather than corrupting the payload. The response object itself is mutated in place, not replaced.

ParameterTypeDescription
$requestServerRequestInterface
$handlerRequestHandlerInterface

Returns ResponseInterface