eonx-com / easy-psr7-factory
Provides an easy way to create PSR7 Request/Response from Symfony Request/Response
Package info
github.com/eonx-com/easy-psr7-factory
Type:symfony-bundle
pkg:composer/eonx-com/easy-psr7-factory
Requires
- php: ^8.1
- nyholm/psr7: ^1.1
- symfony/psr-http-message-bridge: ^1.1 || ^2.0
Requires (Dev)
- guzzlehttp/psr7: ^2.1
- laravel/lumen-framework: ^5.8 || ^6.0 || ^8.0
- phpunit/phpunit: ^9.5 || ^10.0
- symfony/symfony: ^5.4 || ^6.0
- vlucas/phpdotenv: ^3.3 || ^5.2
This package is auto-updated.
Last update: 2026-06-05 04:30:33 UTC
README
---eonx_docs--- title: Introduction weight: 0 ---eonx_docs---
Provides an easy way to create PSR7 Request/Response from Symfony Request/Response.
Installation
The recommended way to install this package is to use Composer.
$ composer require eonx/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 EonX\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... \EonX\EasyPsr7Factory\Bridge\Laravel\EasyPsr7FactoryServiceProvider::class, ],
Lumen
// bootstrap/app.php $app->register(\EonX\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.