zapheus/psr-07-bridge

PSR-07 bridge for Zapheus framework.

v0.1.2 2018-04-18 03:21 UTC

This package is auto-updated.

Last update: 2024-04-04 23:00:30 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Converts PSR-07 packages to Zapheus HTTP messages and vice versa. Also contains an implementation of PSR-07.

Installation

Install PSR-07 Bridge via Composer:

$ composer require zapheus/psr-07-bridge

Basic Usage

PSR-07 to Zapheus

Install a PSR-07 compliant package first (e.g Diactoros):

$ composer require zendframework/zend-diactoros
use Zapheus\Bridge\Psr\Zapheus\Request;
use Zend\Diactoros\ServerRequestFactory;

$psr = ServerRequestFactory::fromGlobals();

// Zapheus\Http\Message\RequestInterface
$request = new Request($psr);

Zapheus to PSR-07

use Zapheus\Bridge\Psr\Interop\ServerRequest;
use Zapheus\Container\Container;
use Zapheus\Http\Message\RequestInterface;
use Zapheus\Http\MessageProvider;

$interface = RequestInterface::class;

$provider = new MessageProvider;

$container = $provider->register(new Container);

$zapheus = $container->get($interface);

// Psr\Http\Message\ServerRequestInterface
$request = new ServerRequest($zapheus);

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

$ composer test

Credits

License

The MIT License (MIT). Please see LICENSE for more information.