@@ -19,10 +19,14 @@ 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 convert
23+ HttpFoundation objects to PSR-7 objects. The following command installs the
24+ ``nyholm/psr7 `` library, a lightweight and fast PSR-7 implementation, but you
25+ can use any of the `libraries that implement psr/http-factory-implementation `_:
26+
27+ .. code-block :: terminal
28+
29+ $ composer require nyholm/psr7
2630
2731 Usage
2832-----
@@ -33,32 +37,35 @@ Converting from HttpFoundation Objects to PSR-7
3337The bridge provides an interface of a factory called
3438:class: `Symfony\\ Bridge\\ PsrHttpMessage\\ HttpMessageFactoryInterface `
3539that builds objects implementing PSR-7 interfaces from HttpFoundation objects.
36- It also provide a default implementation using Zend Diactoros internally.
3740
3841The following code snippet explains how to convert a :class: `Symfony\\ Component\\ HttpFoundation\\ Request `
39- to a ``Zend\Diactoros \ServerRequest `` class implementing the
42+ to a ``Nyholm\Psr7 \ServerRequest `` class implementing the
4043``Psr\Http\Message\ServerRequestInterface `` interface::
4144
42- use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
45+ use Nyholm\Psr7\Factory\Psr17Factory;
46+ use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
4347 use Symfony\Component\HttpFoundation\Request;
4448
4549 $symfonyRequest = new Request([], [], [], [], [], ['HTTP_HOST' => 'dunglas.fr'], 'Content');
4650 // The HTTP_HOST server key must be set to avoid an unexpected error
4751
48- $psr7Factory = new DiactorosFactory();
49- $psrRequest = $psr7Factory->createRequest($symfonyRequest);
52+ $psr17Factory = new Psr17Factory();
53+ $psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
54+ $psrRequest = $psrHttpFactory->createRequest($symfonyRequest);
5055
5156And now from a :class: `Symfony\\ Component\\ HttpFoundation\\ Response ` to a
52- ``Zend\Diactoros \Response `` class implementing the
57+ ``Nyholm\Psr7 \Response `` class implementing the
5358``Psr\Http\Message\ResponseInterface `` interface::
5459
55- use Symfony\Bridge\PsrHttpMessage\Factory\DiactorosFactory;
60+ use Nyholm\Psr7\Factory\Psr17Factory;
61+ use Symfony\Bridge\PsrHttpMessage\Factory\PsrHttpFactory;
5662 use Symfony\Component\HttpFoundation\Response;
5763
5864 $symfonyResponse = new Response('Content');
5965
60- $psr7Factory = new DiactorosFactory();
61- $psrResponse = $psr7Factory->createResponse($symfonyResponse);
66+ $psr17Factory = new Psr17Factory();
67+ $psrHttpFactory = new PsrHttpFactory($psr17Factory, $psr17Factory, $psr17Factory, $psr17Factory);
68+ $psrResponse = $psrHttpFactory->createResponse($symfonyResponse);
6269
6370Converting Objects implementing PSR-7 Interfaces to HttpFoundation
6471~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -89,5 +96,5 @@ to a :class:`Symfony\\Component\\HttpFoundation\\Response` instance::
8996 $symfonyResponse = $httpFoundationFactory->createResponse($psrResponse);
9097
9198.. _`PSR-7` : https://www.php-fig.org/psr/psr-7/
92- .. _`Zend Diactoros ` : https://github.com/zendframework/zend-diactoros
93- .. _`symfony/ psr- http-message-bridge on Packagist ` : https://packagist.org/packages/symfony/ psr- http-message-bridge
99+ .. _`PSR-17 ` : https://www.php-fig.org/psr/psr-17/
100+ .. _`libraries that implement psr/ http-factory-implementation ` : https://packagist.org/providers/ psr/ http-factory-implementation
0 commit comments