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.
Synopsis
Section titled “Synopsis”interface WorkerRuntimeInterface
| Implemented by | RoadRunnerRuntime, SwooleRuntime, FrankenPhpRuntime, SapiRuntime |
| Source | Runtime/Worker/WorkerRuntimeInterface.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
alias(): string | The registry alias, e.g. |
capabilities(): WorkerRuntimeCapabilities | Describes what this host does for itself, so WorkerLoop knows which off-SAPI compensations to apply. |
detectionPriority(): int | Tie-break for auto-detection: the highest priority among the runtimes reporting isSupported() wins. |
isSupported(): bool | Whether this runtime is the one actually hosting the current process. |
run(WorkerLoop $loop): void | Serve requests until the host says to stop. |
alias()
Section titled “alias()”abstract public static function alias(): string
The registry alias, e.g.
“frankenphp”.
Returns string
capabilities()
Section titled “capabilities()”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
detectionPriority()
Section titled “detectionPriority()”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
isSupported()
Section titled “isSupported()”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.
| Parameter | Type | Description |
|---|---|---|
$loop | WorkerLoop |