Code Inc. PSR7 response senders
Clone or download
Latest commit 7108f4d Sep 24, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
src code optimization Sep 24, 2018
.gitignore first commit Feb 23, 2018
LICENSE adds Code Inc. SAS Mar 8, 2018 URL to codeinc/router Sep 24, 2018
composer.json typo Sep 24, 2018

PSR-7 response sender

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.


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();

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()


This library is available through Packagist and can be installed using Composer:

composer require codeinc/psr7-response-sender


This library is published under the MIT license (see the LICENSE file).