https://github.com/yiisoft/psr-emitter
PSR-7 HTTP response emitter
https://github.com/yiisoft/psr-emitter
emitter http psr psr-7 yii3
Last synced: 8 months ago
JSON representation
PSR-7 HTTP response emitter
- Host: GitHub
- URL: https://github.com/yiisoft/psr-emitter
- Owner: yiisoft
- License: bsd-3-clause
- Created: 2025-05-14T13:07:00.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2025-05-21T13:07:50.000Z (9 months ago)
- Last Synced: 2025-06-10T05:28:44.582Z (8 months ago)
- Topics: emitter, http, psr, psr-7, yii3
- Language: PHP
- Homepage:
- Size: 29.3 KB
- Stars: 1
- Watchers: 14
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
Yii PSR Emitter
[](https://packagist.org/packages/yiisoft/psr-emitter)
[](https://packagist.org/packages/yiisoft/psr-emitter)
[](https://github.com/yiisoft/psr-emitter/actions/workflows/build.yml?query=branch%3Amaster)
[](https://codecov.io/gh/yiisoft/psr-emitter)
[](https://dashboard.stryker-mutator.io/reports/github.com/yiisoft/psr-emitter/master)
[](https://github.com/yiisoft/psr-emitter/actions/workflows/static.yml?query=branch%3Amaster)
[](https://shepherd.dev/github/yiisoft/psr-emitter)
[](https://shepherd.dev/github/yiisoft/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](https://getcomposer.org):
```shell
composer require yiisoft/psr-emitter
```
## General usage
Create emitter instance and call `emit()` method with a PSR-7 response:
```php
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:
```php
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
- [Internals](docs/internals.md)
If you need help or have a question, the [Yii Forum](https://forum.yiiframework.com/c/yii-3-0/63) is a good place
for that. You may also check out other [Yii Community Resources](https://www.yiiframework.com/community).
## License
The Yii PSR Emitter is free software. It is released under the terms of the BSD License.
Please see [`LICENSE`](./LICENSE.md) for more information.
Maintained by [Yii Software](https://www.yiiframework.com/).
## Support the project
[](https://opencollective.com/yiisoft)
## Follow updates
[](https://www.yiiframework.com/)
[](https://twitter.com/yiiframework)
[](https://t.me/yii3en)
[](https://www.facebook.com/groups/yiitalk)
[](https://yiiframework.com/go/slack)