loyaltycorp / easy-psr7-factory
Provides an easy way to create PSR7 Request/Response from Symfony Request/Response
Requires
- php: ^7.1
- symfony/psr-http-message-bridge: ^1.1
- zendframework/zend-diactoros: ^2.1
Requires (Dev)
- laravel/lumen-framework: ^5.5
- phpunit/phpunit: ^7.5
- symfony/symfony: ^4.2
- vlucas/phpdotenv: ^3.3
- dev-master / 0.11.x-dev
- v0.10.7
- v0.10.6
- v0.10.5
- v0.10.4
- v0.10.3
- v0.10.2
- v0.10.1
- v0.10.0
- v0.9.4
- v0.9.3
- v0.9.2
- v0.9.1
- v0.9.0
- v0.8.3
- v0.8.2
- v0.8.1
- v0.8.0
- v0.7.11
- v0.7.10
- v0.7.9
- v0.7.8
- v0.7.7
- v0.7.6
- v0.7.5
- v0.7.4
- v0.7.3
- v0.7.2
- v0.7.0
- v0.6.14
- v0.6.13
- v0.6.12
- v0.6.11
- v0.6.10
- v0.6.9
- v0.6.8
- v0.6.7
- v0.6.6
- v0.6.5
- v0.6.4
- v0.6.3
- v0.6.2
- v0.6.1
- v0.6.0
- v0.5.1
- v0.4.5
- v0.4.4
- v0.4.3
- v0.4.2
- v0.4.1
- v0.4.0
- v0.3.4
- v0.3.3
- v0.3.2
- v0.3.1
- v0.3.0
- v0.2.1
- v0.2.0
- v0.1.1
This package is auto-updated.
Last update: 2019-11-25 05:32:50 UTC
README
Provides an easy way to create PSR7 Request/Response from Symfony Request/Response.
Documentation
Installation
The recommended way to install this package is to use Composer.
$ composer require loyaltycorp/psr7-factory
How it works
You are working on a PHP application using the well known Symfony HttpFoundation Component and you want to implement some logic which can be used in any other PHP application using Request/Response? This package is for you!
The EasyPsr7Factory will allow you to create a PSR-7 ServerRequestInterface implementation from a Symfony HttpFoundation Request and then will also allow you to create a Symfony Response from a PSR-7 ResponseInterface.
Usage
use LoyaltyCorp\EasyPsr7Factory\EasyPsr7Factory; // Gives you a \Psr\Http\Message\ServerRequestInterface based on all values from the $symfonyRequest $serverRequest = (new EasyPsr7Factory())->createRequest($symfonyRequest); // Gives you a \Symfony\Component\HttpFoundation\Response based on all values from the $psr7Response $symfonyResponse = (new EasyPsr7Factory())->createResponse($psr7Response);
Laravel / Lumen
You like the idea and you're not using Symfony but Laravel/Lumen instead? Lucky you this is an easy use case :) Laravel/Lumen Request/Response classes both extend the Symfony ones so this EasyPsr7Factory works for you too!
And just to make your day, it comes with a service provider allowing you to create requests and responses from anywhere you want in your application :)
Laravel
// config/app.php 'providers' => [ // Other Service Providers... \LoyaltyCorp\EasyPsr7Factory\Bridge\Laravel\EasyPsr7FactoryServiceProvider::class, ],
Lumen
// bootstrap/app.php $app->register(\LoyaltyCorp\EasyPsr7Factory\Bridge\Laravel\EasyPsr7FactoryServiceProvider::class);
Contributing
None of the existing implementations fit your needs? Don't hesitate to create an Issue about it or event a Pull Request to help us grow the package.