codeinc/psr7-response-sender

This package is abandoned and no longer maintained. No replacement package was suggested.

Code Inc. PSR-7 response senders

1.3.2 2018-09-24 06:37 UTC

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