codeinc / psr7-response-sender
Code Inc. PSR-7 response senders
Requires
- php: >=7.1
- codeinc/http-reason-phrase-lookup: ^1.0
- psr/http-message: ^1.0
- psr/http-server-handler: ^1.0
Requires (Dev)
- codeinc/middleware-test-kit: ^1.0
- guzzlehttp/psr7: ^1.4
- hansott/psr7-cookies: ^1.0
- phpunit/phpunit: ^7
Suggests
- codeinc/psr7-responses: A collection of PSR-7 responses
This package is auto-updated.
Last update: 2020-02-04 11:48:23 UTC
README
This library is a companion to the codeinc/router
written in PHP 7. It provides the ResponseSender
responder to stream PSR-7 responses to a web browser and the interface ResponseSenderInterface
for PSR-7 reponse senders.
A response sender is capable of streaming anything implementing the PSR-7 ResponseInterface
.
Usage
<?php use CodeInc\PSR7ResponseSender\ResponseSender; use GuzzleHttp\Psr7\Response; // a response can be anything implementing ResponseInterface, here the Guzzle implementation $response = new Response(); // sends the response to the web browser $sender = new ResponseSender(); $sender->send($response);
By default ResponseSender
removes all PHP native HTTP headers. You can change this behavior using the boolean constructor operator or using the methods removePhpHttpHeaders()
and sendPhpHttpHeaders()
.
A second class GzResponseSender
is provived to send gzip compressed responses using ob_start()
and ob_gzhandler()
Installation
This library is available through Packagist and can be installed using Composer:
composer require codeinc/psr7-response-sender
License
This library is published under the MIT license (see the LICENSE
file).