Skip to content

WorkerRuntimeRegistry

Process-global registry mapping short runtime aliases (e.g.

“frankenphp”, “roadrunner”) to the WorkerRuntimeInterface class that implements them. Mirrors FilesystemDriverRegistry exactly.

Only sapi and frankenphp ship in core. Other hosts register their own alias from their own plugin (e.g. quioteframework/worker-roadrunner’s WorkerRoadRunnerPlugin), which is why WorkerRuntimeRegistry::detect() lives here rather than as a hardcoded list in the Kernel.

final class WorkerRuntimeRegistry

SourceRuntime/Worker/WorkerRuntimeRegistry.php
MethodDescription
aliases(): array<string, class-string<WorkerRuntimeInterface>>
detect(): class-string<WorkerRuntimeInterface>The registered runtime that claims the current process: the highest detectionPriority() among those reporting isSupported(), ties broken by registration order so the result is deterministic.
has(string $alias): boolWhether $alias has been registered.
instantiateClassFor(string $aliasOrClass): class-string<WorkerRuntimeInterface>
register(string $alias, class-string<WorkerRuntimeInterface> $runtimeClass): void
reset(): voidTest isolation: restore the built-in aliases only.
resolve(string $aliasOrClass): stringA string that is not a registered alias is returned unchanged, so a fully-qualified class name passes through.

public static function aliases(): array<string, class-string<WorkerRuntimeInterface>>

Returns array``<``string``, ``class-string``<WorkerRuntimeInterface>``>

public static function detect(): class-string<WorkerRuntimeInterface>

The registered runtime that claims the current process: the highest detectionPriority() among those reporting isSupported(), ties broken by registration order so the result is deterministic.

Always resolves — SapiRuntime claims every process at PHP_INT_MIN — so callers never have to handle “no runtime”.

Returns class-string``<WorkerRuntimeInterface>

public static function has(string $alias): bool

Whether $alias has been registered.

Only tests the alias table; a fully-qualified class name that WorkerRuntimeRegistry::resolve() would happily pass through is not an alias and reports false here.

ParameterTypeDescription
$aliasstring

Returns bool

public static function instantiateClassFor(string $aliasOrClass): class-string<WorkerRuntimeInterface>

ParameterTypeDescription
$aliasOrClassstring

Returns class-string``<WorkerRuntimeInterface>

public static function register(string $alias, class-string<WorkerRuntimeInterface> $runtimeClass): void

ParameterTypeDescription
$aliasstring
$runtimeClassclass-string``<WorkerRuntimeInterface>

public static function reset(): void

Test isolation: restore the built-in aliases only.

public static function resolve(string $aliasOrClass): string

A string that is not a registered alias is returned unchanged, so a fully-qualified class name passes through.

ParameterTypeDescription
$aliasOrClassstring

Returns string