Skip to content

ResponseEmitterInterface

Sends a PSR-7 response back to whatever is on the other end of the current worker runtime: the SAPI (header()/echo), a RoadRunner relay, a Swoole response object.

Each runtime owns its emitter, which is why the Kernel no longer constructs one. Lifetime differs deliberately: the SAPI and RoadRunner emitters live as long as the worker, while Swoole’s wraps the per-request response object.

interface ResponseEmitterInterface

Implemented bySapiEmitter, RoadRunnerResponseEmitter, SwooleResponseEmitter
SourceRuntime/Emitter/ResponseEmitterInterface.php
MethodDescription
emit(ResponseInterface $response): voidWrites the status line, headers and body out through the host’s channel.
supportsStreaming(): boolWhether this emitter can flush a body incrementally, i.e.

abstract public function emit(ResponseInterface $response): void

Writes the status line, headers and body out through the host’s channel.

Called once per request by the runtime, after WorkerLoop::handle() has produced the response. An emitter reporting ResponseEmitterInterface::supportsStreaming() must deliver an SseStream body chunk by chunk rather than casting it to a string.

ParameterTypeDescription
$responseResponseInterface

abstract public function supportsStreaming(): bool

Whether this emitter can flush a body incrementally, i.e.

whether a SseStream body will actually stream. When false, core.worker.sse_fallback decides what happens instead.

Returns bool