2017 © Pedro Peláez
 

library stack-psr7-bridge

StackPHP Middleware for converting Symfony Http abstractions to PSR-7 and back.

image

h4cc/stack-psr7-bridge

StackPHP Middleware for converting Symfony Http abstractions to PSR-7 and back.

  • Monday, September 21, 2015
  • by h4cc
  • Repository
  • 2 Watchers
  • 15 Stars
  • 36 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 20 % Grown

The README.md

h4cc/stack-psr7-bridge

StackPHP Middleware for using Symfony HttpKernel Applications and PSR-7 Application transparent., (*1)

Build Status HHVM Status Scrutinizer Code Quality Code Coverage, (*2)

This Middleware tries to make using Symfony HttpKernel Application and PSR-7 as easy as possible., (*3)

Wrapped applications can be:, (*4)

  • Any Symfony HttpKernel
  • Any Callback expecting function(RequestInterface $request, ResponseInterface $response, $next = null)

It does not matter what kind of application is wrapped, the bridge will convert incoming requests and outgoing responses accordingly to the used interface., (*5)

The implementation this middleware is based on is https://github.com/symfony/psr-http-message-bridge., (*6)

Usage

By default, the Symfony HttpFoundation and HttpKernel are used. For PSR-7, the Zend-Diactoros implementation is used. These implementations can be changed if needed., (*7)

Wrapping a HttpKernel

<?php

$bridge = new Psr7Bridge($yourHttpKernel);

// Handling PSR-7 requests
$psr7Response = $bridge->__invoke($psr7Request, $psr7Response);

// Handling Symfony requests
$symfonyResponse = $bridge->_handle($symfonyRequest);

Wrapping a PSR-7 callback

The expected PSR-7 callback format is not yet defined by PHP-FIG and might be subject to change!, (*8)

<?php

$psr7Callback = function(RequestInterface $request, ResponseInterface $response, $next = null) {
  // Creating a PSR-7 Response here ...
};

$bridge = new Psr7Bridge($psr7Callback);

// Handling PSR-7 requests
$psr7Response = $bridge->__invoke($psr7Request, $psr7Response);

// Handling Symfony requests
$symfonyResponse = $bridge->_handle($symfonyRequest);

Installation

The recommended way to install stack-psr7-bridge is through Composer:, (*9)

composer require h4cc/stack-psr7-bridge

Protip: you should browse the h4cc/stack-psr7-bridge page to choose a stable version to use, avoid the @stable meta constraint., (*10)

License

h4cc/stack-psr7-bridge is released under the MIT License. See the bundled LICENSE file for details., (*11)

The Versions

21/09 2015

dev-master

9999999-dev

StackPHP Middleware for converting Symfony Http abstractions to PSR-7 and back.

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

08/06 2015