Skip to content

WorkerRequestFactory

The single seam every worker runtime funnels its inbound request through, so reverse-proxy correction happens identically whether the request came from superglobals (a SAPI) or from a server that handed us a PSR-7 object (RoadRunner, Swoole).

Previously this lived in Kernel and applied the correction by writing to $_SERVER before building the request, which is unavailable off-SAPI and untestable anywhere. Here it is a pure transformation of a PSR-7 request.

final class WorkerRequestFactory

SourceRuntime/Request/WorkerRequestFactory.php

public function __construct(ForwardedHeaderResolver $resolver = new ForwardedHeaderResolver(…), ?bool $trustForwardedHeaders = null): mixed

ParameterTypeDescription
$resolverForwardedHeaderResolver
$trustForwardedHeaders?``bool

Returns mixed

MethodDescription
fromGlobals(): WebRequestBuild the request from PHP’s superglobals.
fromPsr(ServerRequestInterface $request): WebRequestApply reverse-proxy correction and hand back a WebRequest the rest of the framework can rely on.

public function fromGlobals(): WebRequest

Build the request from PHP’s superglobals.

Only valid under a runtime whose capabilities report populatesSuperglobals.

Returns WebRequest

public function fromPsr(ServerRequestInterface $request): WebRequest

Apply reverse-proxy correction and hand back a WebRequest the rest of the framework can rely on.

ParameterTypeDescription
$requestServerRequestInterface

Returns WebRequest