yiisoft / psr-emitter
PSR-7 HTTP response emitter
Fund package maintenance!
Opencollective
yiisoft
Requires
- php: 8.1 - 8.4
- psr/http-message: ^2.0
- yiisoft/friendly-exception: ^1.1
Requires (Dev)
- httpsoft/http-message: ^1.1.6
- maglnet/composer-require-checker: ^4.7.1
- phpunit/phpunit: ^10.5.46
- psr/http-server-middleware: ^1.0.2
- rector/rector: ^2.0.16
- roave/infection-static-analysis-plugin: ^1.35
- spatie/phpunit-watcher: ^1.24
- vimeo/psalm: ^5.26.1 || ^6.10.3
- xepozz/internal-mocker: ^1.4.1
Suggests
- psr/http-server-middleware: To use emitter as middleware.
This package is auto-updated.
Last update: 2025-05-21 13:08:09 UTC
README
Yii PSR Emitter
The package provides EmitterInterface
that is responsible for sending PSR-7 HTTP responses as well as several implementations of the interface:
SapiEmitter
- sends a response using standard PHP Server API;FakeEmiiter
- a fake emitter that does nothing, except for capturing response (useful for testing purposes).
Additionally, the package provides EmitterMiddleware
PSR-15 middleware that can be used in an application to send
a response by any EmitterInterface
implementation.
Requirements
- PHP 8.1 or higher.
Installation
The package could be installed with Composer:
composer require yiisoft/psr-emitter
General usage
Create emitter instance and call emit()
method with a PSR-7 response:
use Psr\Http\Message\ResponseInterface; use Yiisoft\PsrEmitter\SapiEmitter; /** @var Response $response */ $emitter = new SapiEmitter(); $emitter->emit($response);
You can customize the buffer size (by default, 8MB) for large response bodies:
use Psr\Http\Message\ResponseInterface; use Yiisoft\PsrEmitter\SapiEmitter; /** @var Response $response */ $emitter = new SapiEmitter(4_194_304); // Buffer size is 4MB // Response content will be sent in chunks of 4MB $emitter->emit($response);
Documentation
If you need help or have a question, the Yii Forum is a good place for that. You may also check out other Yii Community Resources.
License
The Yii PSR Emitter is free software. It is released under the terms of the BSD License.
Please see LICENSE
for more information.
Maintained by Yii Software.