This repository has been archived by the owner. It is now read-only.
Code Inc. PSR7 response senders
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src
.gitignore
LICENSE
README.md
composer.json

README.md

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.

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