Skip to content

SwooleServerFactory

Creates the HTTP server SwooleRuntime binds and runs.

The seam that keeps the runtime testable: SwooleRuntime takes one of these optionally and falls back to NativeSwooleServerFactory, which builds a real Swoole\Http\Server and refuses when ext-swoole is absent. A test supplies its own implementation and gets a SwooleServerInterface double, so the host, port and settings the runtime computed can be asserted without the extension installed.

Implementors must return a server bound to the given host and port with $settings applied, ready for the runtime to attach its worker-start and request handlers to.

interface SwooleServerFactory

Implemented byNativeSwooleServerFactory
SourceSwooleServerFactory.php
MethodDescription
create(string $host, int $port, array<string, mixed> $settings): SwooleServerInterface

abstract public function create(string $host, int $port, array<string, mixed> $settings): SwooleServerInterface

Passed straight to Swoole’s set().

ParameterTypeDescription
$hoststring
$portint
$settingsarray``<``string``, ``mixed``>Passed straight to Swoole’s set().

Returns SwooleServerInterface