2017 © Pedro Peláez
 

library http-emitter

Emitting psr-7 responses.

image

narrowspark/http-emitter

Emitting psr-7 responses.

  • Wednesday, June 6, 2018
  • by dani33
  • Repository
  • 1 Watchers
  • 3 Stars
  • 8,635 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

Http Response Emitter

Emits a Response to the PHP Server API.

, (*1)

The available emitter implementations are:, (*2)

- `Narrowspark\HttpEmitter\SapiEmitter`
- `Narrowspark\HttpEmitter\SapiStreamEmitter`.

Note: Each use the native PHP functions header() and echo in order to emit the response., (*3)

Note: If headers have been sent, or the output buffer exists and has a non-zero length, the emitters raise an exception, as mixed PSR-7 / output buffer content creates a blocking issue., (*4)

If you are emitting content via echo, print, var_dump, etc., or not catching PHP errors / exceptions, you will need to either fix your application to always work with a PSR-7 response. Or provide your own emitters that allow mixed output mechanisms., (*5)

Installation

composer require narrowspark/http-emitter

Use

How to use the SapiEmitter:, (*6)

<?php

use Narrowspark\HttpEmitter\SapiEmitter;

$response = new \Response();
$response->getBody()->write("some content\n");

$emitter = new SapiEmitter();
$emitter->emit($response);

If you missing the Content-Length header you can use the \Narrowspark\HttpEmitter\Util\Util::injectContentLength static method., (*7)

<?php

use Narrowspark\HttpEmitter\Util;

$response = new \Response();

$response = Util::injectContentLength($response);

Contributing

If you would like to help take a look at the list of issues and check our Contributing guild., (*8)

Note: Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms., (*9)

License

The Narrowspark http-emitter is open-sourced software licensed under the MIT license, (*10)

The Versions

07/04 2017

v0.1.2

0.1.2.0

Emitting psr-7 responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http emitter narrowspark

04/04 2017

v0.1.1

0.1.1.0

Emitting psr-7 responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http emitter narrowspark

04/04 2017

v0.1.0

0.1.0.0

Emitting psr-7 responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

psr-7 http emitter narrowspark