8000 Merge branch '3.4' into 4.2 · symfony/symfony-docs@0cd91c0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 0cd91c0

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: Update security_checker.rst Use nyholm/psr17 instead of deprecated Zend Diactoros
2 parents 042f444 + 16a01aa commit 0cd91c0

File tree

3 files changed

+25
-18
lines changed

3 files changed

+25
-18
lines changed

components/psr7.rst

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -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
3337
The bridge provides an interface of a factory called
3438
:class:`Symfony\\Bridge\\PsrHttpMessage\\HttpMessageFactoryInterface`
3539
that builds objects implementing PSR-7 interfaces from HttpFoundation objects.
36-
It also provide a default implementation using Zend Diactoros internally.
3740

3841
The 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

5156
And 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+ 10000
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

6370
Converting 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

performance.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ overhead that can be avoided as follows:
7575
opcache.validate_timestamps=0
7676
7777
After each deploy, you must empty and regenerate the cache of OPcache. Otherwise
78-
you won't see the updates made in the application. Given than in PHP, the CLI
78+
you won't see the updates made in the application. Given that in PHP, the CLI
7979
and the web processes don't share the same OPcache, you cannot clear the web
8080
server OPcache by executing some command in your terminal. These are some of the
8181
possible solutions:

security/security_checker.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ FriendsOfPHP organization.
3030

3131
The ``security:check`` command terminates with a non-zero exit code if
3232
any of your dependencies is affected by a known security vulnerability.
33-
This allows you to add it to your project build process and your continuous
34-
integration workflows.
33+
This way you can add it to your project build process and your continuous
34+
integration workflows to make them fail when there are vulnerabilities.
3535

3636
.. tip::
3737

0 commit comments

Comments
 (0)
0