@@ -19,10 +19,13 @@ Alternatively, you can clone the `<https://github.com/symfony/psr-http-message-b
1919
2020.. include :: /components/require_autoload.rst.inc
2121
22- The bridge also needs a PSR-7 implementation to allow converting HttpFoundation
23- objects to PSR-7 objects. It provides native support for `Zend Diactoros `_.
24- Use Composer (`zendframework/zend-diactoros on Packagist <https://packagist.org/packages/zendframework/zend-diactoros >`_)
25- or refer to the project documentation to install it.
22+ The bridge also needs a PSR-7 and `PSR-17 `_ implementation to allow converting
23+ HttpFoundation objects to PSR-7 objects. See a full list of PSR-17 libraries on
24+ that provide `psr/http-factory-implementation `_ on Packagist.org. Example:
25+
26+ .. code-block :: terminal
27+
28+ $ composer require nyholm/psr7
2629
2730 Usage
2831-----
@@ -33,32 +36,35 @@ Converting from HttpFoundation Objects to PSR-7
3336The bridge provides an interface of a factory called
3437:class: `Symfony\\ Bridge\\ PsrHttpMessage\\ HttpMessageFactoryInterface `
3538that builds objects implementing PSR-7 interfaces from HttpFoundation objects.
36- It also provide a default implementation using Zend Diactoros internally.
3739
3840The following code snippet explains how to convert a :class: `Symfony\\ Component\\ HttpFoundation\\ Request `
39- to a ``Zend\Diactoros \ServerRequest `` class implementing the
41+ to a ``Nyholm\Psr7 \ServerRequest `` class implementing the
4042``Psr\Http\Message\ServerRequestInterface `` interface::
4143
42- use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
44+ use Nyholm\Psr7\Factory\Psr17Factory;
45+ use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
4346 use Symfony\Component\HttpFoundation\Request;
4447
4548 $symfonyRequest = new Request([], [], [], [], [], ['HTTP_HOST' => 'dunglas.fr'], 'Content');
4649 // The HTTP_HOST server key must be set to avoid an unexpected error
4750
48- $psr7Factory = new DiactorosFactory();
49- $psrRequest = $psr7Factory->createRequest($symfonyRequest);
51+ $psr17Factory = new Psr17Factory();
52+ $psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
53+ $psrRequest = $psrHttpFactory->createRequest($symfonyRequest);
5054
5155And now from a :class: `Symfony\\ Component\\ HttpFoundation\\ Response ` to a
52- ``Zend\Diactoros \Response `` class implementing the
56+ ``Nyholm\Psr7 \Response `` class implementing the
5357``Psr\Http\Message\ResponseInterface `` interface::
5458
55- use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
59+ use Nyholm\Psr7\Factory\Psr17Factory;
60+ use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
5661 use Symfony\Component\HttpFoundation\Response;
5762
5863 $symfonyResponse = new Response('Content');
5964
60- $psr7Factory = new DiactorosFactory();
61- $psrResponse = $psr7Factory->createResponse($symfonyResponse);
65+ $psr17Factory = new Psr17Factory();
66+ $psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
67+ $psrResponse = $psrHttpFactory->createResponse($symfonyResponse);
6268
6369Converting Objects implementing PSR-7 Interfaces to HttpFoundation
6470~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -89,5 +95,6 @@ to a :class:`Symfony\\Component\\HttpFoundation\\Response` instance::
8995 $symfonyResponse = $httpFoundationFactory->createResponse($psrResponse);
9096
9197.. _`PSR-7` : https://www.php-fig.org/psr/psr-7/
92- .. _`Zend Diactoros` : https://github.com/zendframework/zend-diactoros
98+ .. _`PSR-17` : https://www.php-fig.org/psr/psr-17/
99+ .. _`psr/http-factory-implementation` : https://packagist.org/providers/psr/http-factory-implementation
93100.. _`symfony/psr-http-message-bridge on Packagist` : https://packagist.org/packages/symfony/psr-http-message-bridge
0 commit comments