SapiEmitter
API reference › PSR bridge › emitter › SapiEmitter
Emits PSR-7 responses through PHP SAPI.
Methods
Section titled “Methods”| Method | Description | Defined 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 |
Method details
Section titled “Method details”__construct()
Section titled “__construct() ”public function __construct(int $bufferLength = 8192)Configures the maximum bytes read in each body-emission chunk.
Parameters
| Parameter | Type | Description |
|---|---|---|
$bufferLength | int | Positive chunk size in bytes; defaults to 8192. |
Throws
yii\base\InvalidArgumentException: when the buffer length is less than 1.
emit()
Section titled “emit() ”public function emit(Psr\Http\Message\ResponseInterface $response, bool $body = true): voidEmits 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
| Parameter | Type | Description |
|---|---|---|
$response | Psr\ | Response to emit. |
$body | bool | Whether to emit the body when allowed by status code. |
Throws
yii2\extensions\psrbridge\exception\HeadersAlreadySentException: when PHP has already sent headers.yii2\extensions\psrbridge\exception\OutputAlreadySentException: when the current output buffer contains bytes.RuntimeException: when reading or positioning the body stream fails.