Skip to content

NativeSwooleServerFactory

Builds the real \Swoole\Http\Server.

The only place in this package that names it, alongside SwooleRequestSnapshotFactory and SwooleResponseWriter.

SWOOLE_BASE (single-process-per-connection) rather than SWOOLE_PROCESS: there is no separate master routing layer to gain from, and BASE keeps each request inside one worker for its whole lifetime, which is what Quiote’s process-global state requires. See SwooleRuntime for the rest of that reasoning.

final class NativeSwooleServerFactory implements SwooleServerFactory

ImplementsSwooleServerFactory
SourceNativeSwooleServerFactory.php

public function __construct(bool|null $extensionAvailable = null): mixed

Overridable so the missing-extension guard is testable on a machine that does have ext-swoole, instead of being a test that skips itself depending on the environment.

ParameterTypeDescription
$extensionAvailable`bool““null`

Returns mixed

MethodDescription
create(string $host, int $port, array $settings): SwooleServerInterfaceBuilds a \Swoole\Http\Server bound to $host:$port in SWOOLE_BASE mode.

public function create(string $host, int $port, array $settings): SwooleServerInterface

Builds a \Swoole\Http\Server bound to $host:$port in SWOOLE_BASE mode.

The settings array is passed to the server’s own set() untouched. The server is created but not started; SwooleServerInterface::start() does that.

ParameterTypeDescription
$hoststring
$portint
$settingsarray

Returns SwooleServerInterface

ThrowsWhen
RuntimeExceptionif ext-swoole is not available in this process.