Skip to content

Commit 2625a78

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: [HttpClient] make HttpClient::create() return an AmpHttpClient when amphp/http-client is found but curl is not or too old
2 parents 9b36553 + 9786553 commit 2625a78

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

http_client.rst

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -980,15 +980,24 @@ To leverage all these design benefits, the cURL extension is needed.
980980
Enabling cURL Support
981981
~~~~~~~~~~~~~~~~~~~~~
982982

983-
This component supports both the native PHP streams and cURL to make the HTTP
984-
requests. Although both are interchangeable and provide the same features,
985-
including concurrent requests, HTTP/2 is only supported when using cURL.
983+
This component can make HTTP requests using native PHP streams and the
984+
``amphp/http-client`` and cURL libraries. Although they are interchangeable and
985+
provide the same features, including concurrent requests, HTTP/2 is only supported
986+
when using cURL or ``amphp/http-client``.
987+
988+
.. note::
989+
990+
To use the :class:`Symfony\\Component\\HttpClient\\AmpHttpClient`, the
991+
`amphp/http-client`_ package must be installed.
986992

987993
The :method:`Symfony\\Component\\HttpClient\\HttpClient::create` method
988-
selects the cURL transport if the `cURL PHP extension`_ is enabled and falls
989-
back to PHP streams otherwise. If you prefer to select the transport
990-
explicitly, use the following classes to create the client::
994+
selects the cURL transport if the `cURL PHP extension`_ is enabled. It falls
995+
back to ``AmpHttpClient`` if cURL couldn't be found or is too old. Finally, if
996+
``AmpHttpClient`` is not available, it falls back to PHP streams.
997+
If you prefer to select the transport explicitly, use the following classes
998+
to create the client::
991999

1000+
use Symfony\Component\HttpClient\AmpHttpClient;
9921001
use Symfony\Component\HttpClient\CurlHttpClient;
9931002
use Symfony\Component\HttpClient\NativeHttpClient;
9941003

@@ -998,9 +1007,12 @@ explicitly, use the following classes to create the client::
9981007
// uses the cURL PHP extension
9991008
$client = new CurlHttpClient();
10001009

1010+
// uses the client from the `amphp/http-client` package
1011+
$client = new AmpHttpClient();
1012+
10011013
When using this component in a full-stack Symfony application, this behavior is
10021014
not configurable and cURL will be used automatically if the cURL PHP extension
1003-
is installed and enabled. Otherwise, the native PHP streams will be used.
1015+
is installed and enabled, and will fall back as explained above.
10041016

10051017
Configuring CurlHttpClient Options
10061018
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1050,7 +1062,7 @@ HTTP/2 Support
10501062
When requesting an ``https`` URL, HTTP/2 is enabled by default if one of the
10511063
following tools is installed:
10521064

1053-
* The `libcurl`_ package version 7.36 or higher;
1065+
* The `libcurl`_ package version 7.36 or higher, used with PHP >= 7.2.17 / 7.3.4;
10541066
* The `amphp/http-client`_ Packagist package version 4.2 or higher.
10551067

10561068
To force HTTP/2 for ``http`` URLs, you need to enable it explicitly via the
@@ -1100,9 +1112,9 @@ To force HTTP/2 for ``http`` URLs, you need to enable it explicitly via the
11001112
11011113
$client = HttpClient::create(['http_version' => '2.0']);
11021114
1103-
Support for HTTP/2 PUSH works out of the box when libcurl >= 7.61 is used with
1104-
PHP >= 7.2.17 / 7.3.4: pushed responses are put into a temporary cache and are
1105-
used when a subsequent request is triggered for the corresponding URLs.
1115+
Support for HTTP/2 PUSH works out of the box when using a compatible client:
1116+
pushed responses are put into a temporary cache and are used when a
1117+
subsequent request is triggered for the corresponding URLs.
11061118

11071119
Processing Responses
11081120
--------------------

0 commit comments

Comments
 (0)