2017 © Pedro Peláez
 

library net-http-response

Specialized response and body classes plus response emitter

image

binsoul/net-http-response

Specialized response and body classes plus response emitter

  • Wednesday, April 27, 2016
  • by binsoul
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

net-http-response

Latest Version on Packagist ![Software License][ico-license] Total Downloads, (*1)

Install

Via composer:, (*2)

``` bash $ composer require binsoul/net-http-response, (*3)


This package provides PSR-7 ResponseInterface compatible response classes specialized for known HTTP status codes and body implementations which extend the PSR-7 StreamInterface with some useful methods. The included response emitter can output responses to different target environments. ## Usage Output a text response on a web server: ``` php emit($response, new SapiTarget()); ``` Capture and display response headers and body: ``` php \s+/m", ' => ', var_export($value, true))); } $response = new OkResponse(new TextBody('Hello world!')); $target = new CaptureTarget(); $emitter = new DefaultEmitter(); $emitter->emit($response, $target); ?> <!DOCTYPE html> <html> <body> <h1>Headers</h1> <pre><?= dump($target->getHeaders()) ?></pre> <h1>Body</h1> <pre><?= dump($target->getBody()) ?></pre> </body> </html>

Testing

bash $ composer test, (*4)

License

The MIT License (MIT). Please see License File for more information., (*5)

The Versions