0

I have written an own HTTP library that implements the PSR-7 interfaces. I use this library in a second library that does some business logic and may return either a response or request in PSR-7 standard.

For my application I use Silex / Symfony modules. In the controller I have to return a Symfony response.

How can I transform a PSR-7 response to a Symfony response? I only find bridges for vice versa, transforming a Symfony response to a PSR-7 response.

Cravid
  • 653
  • 2
  • 7
  • 22
  • Does this not help: http://symfony.com/doc/current/cookbook/psr7.html#converting-objects-implementing-psr-7-interfaces-to-httpfoundation? By the way, in Symfony 2 the conversion happens automatically. Your controller just needs to return a psr7 response. I would expect that Silex could be configured to do the same. – Cerad Nov 06 '15 at 15:08

1 Answers1

3

Try by this way:

use Symfony\Bridge\PsrHttpMessage\Factory\HttpFoundationFactory;

$httpFoundationFactory = new HttpFoundationFactory();

// convert a Response
// $psrResponse is an instance of Psr\Http\Message\ResponseInterface
$symfonyResponse = $httpFoundationFactory->createResponse($psrResponse);

Hope it will help you.

scoolnico
  • 3,055
  • 14
  • 24