Skip to content

WorkerRuntimeInterface

A host that drives Quiote’s request loop: the PHP SAPI, a FrankenPHP worker, a RoadRunner worker, a Swoole HTTP server.

The runtime owns both ends of a request — acquiring it and emitting the response — because that is precisely what differs between hosts. A SAPI takes its input from superglobals and writes with header()/echo; a CLI-hosted server is handed a request object and hands back a response object, and can do neither of those things. Everything in between is WorkerLoop’s job, so a runtime is typically well under a hundred lines.

Runtimes register themselves with WorkerRuntimeRegistry under a short alias; core ships sapi and frankenphp, and packages contribute the rest from their plugin.

interface WorkerRuntimeInterface

Implemented byRoadRunnerRuntime, SwooleRuntime, FrankenPhpRuntime, SapiRuntime
SourceRuntime/Worker/WorkerRuntimeInterface.php
MethodDescription
alias(): stringThe registry alias, e.g.
capabilities(): WorkerRuntimeCapabilitiesDescribes what this host does for itself, so WorkerLoop knows which off-SAPI compensations to apply.
detectionPriority(): intTie-break for auto-detection: the highest priority among the runtimes reporting isSupported() wins.
isSupported(): boolWhether this runtime is the one actually hosting the current process.
run(WorkerLoop $loop): voidServe requests until the host says to stop.

abstract public static function alias(): string

The registry alias, e.g.

“frankenphp”.

Returns string

abstract public function capabilities(): WorkerRuntimeCapabilities

Describes what this host does for itself, so WorkerLoop knows which off-SAPI compensations to apply.

Read once when the loop is built; the answer must not vary between requests on the same runtime instance.

Returns WorkerRuntimeCapabilities

abstract public static function detectionPriority(): int

Tie-break for auto-detection: the highest priority among the runtimes reporting isSupported() wins.

SapiRuntime sits at PHP_INT_MIN so it is only ever chosen when nothing else claims the process.

Returns int

abstract public static function isSupported(): bool

Whether this runtime is the one actually hosting the current process.

Must be cheap and free of side effects — it is called for every registered runtime during auto-detection, before anything has booted.

Returns bool

abstract public function run(WorkerLoop $loop): void

Serve requests until the host says to stop.

Implementations acquire a request, pass it to WorkerLoop::handle() (which never throws), emit the response, and call WorkerLoop::afterRequest() at the boundary — the last one in a finally, so state is reset even when emission fails.

ParameterTypeDescription
$loopWorkerLoop