Skip to content
PHP Ecosystem
Explore

SapiEmitter

API reference › PSR bridge › emitter › SapiEmitter

final classyii2\extensions\psrbridge\emitter\SapiEmitter
Sourcesrc/emitter/SapiEmitter.php

Emits PSR-7 responses through PHP SAPI.

MethodDescriptionDefined by
__construct()Configures the maximum bytes read in each body-emission chunk.SapiEmitter
emit()Emits status, headers, and optionally a readable body through PHP SAPI.SapiEmitter
public function __construct(int $bufferLength = 8192)

Configures the maximum bytes read in each body-emission chunk.

Parameters

ParameterTypeDescription
$bufferLengthintPositive chunk size in bytes; defaults to 8192.

Throws

public function emit(Psr\Http\Message\ResponseInterface $response, bool $body = true): void

Emits status, headers, and optionally a readable body through PHP SAPI.

Suppresses the body for statuses recognized by HttpNoBodyStatus. The caller must pass false for HEAD because this method has no originating request. Reads are bounded by the configured chunk size; after-send lifecycle processing remains the caller’s responsibility.

Parameters

ParameterTypeDescription
$responsePsr\Http\Message\ResponseInterfaceResponse to emit.
$bodyboolWhether to emit the body when allowed by status code.

Throws