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.
Synopsis
Section titled “Synopsis”interface ResponseEmitterInterface
| Implemented by | SapiEmitter, RoadRunnerResponseEmitter, SwooleResponseEmitter |
| Source | Runtime/Emitter/ResponseEmitterInterface.php |
Methods
Section titled “Methods”| Method | Description |
|---|---|
emit(ResponseInterface $response): void | Writes the status line, headers and body out through the host’s channel. |
supportsStreaming(): bool | Whether this emitter can flush a body incrementally, i.e. |
emit()
Section titled “emit()”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.
| Parameter | Type | Description |
|---|---|---|
$response | ResponseInterface |
supportsStreaming()
Section titled “supportsStreaming()”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