Skip to content

Commit 70fee6d

Browse files
committed
Merge branch '5.4' into 6.3
* 5.4: [HttpClient] make HttpClient::create() return an AmpHttpClient when amphp/http-client is found but curl is not or too old
2 parents 6598347 + f78344d commit 70fee6d

File tree

1 file changed

+27
-11
lines changed

1 file changed

+27
-11
lines changed

http_client.rst

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -975,15 +975,28 @@ To leverage all these design benefits, the cURL extension is needed.
975975
Enabling cURL Support
976976
~~~~~~~~~~~~~~~~~~~~~
977977

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

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

999+
use Symfony\Component\HttpClient\AmpHttpClient;
9871000
use Symfony\Component\HttpClient\CurlHttpClient;
9881001
use Symfony\Component\HttpClient\NativeHttpClient;
9891002

@@ -993,9 +1006,12 @@ explicitly, use the following classes to create the client::
9931006
// uses the cURL PHP extension
9941007
$client = new CurlHttpClient();
9951008

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

10001016
Configuring CurlHttpClient Options
10011017
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1045,7 +1061,7 @@ HTTP/2 Support
10451061
When requesting an ``https`` URL, HTTP/2 is enabled by default if one of the
10461062
following tools is installed:
10471063

1048-
* The `libcurl`_ package version 7.36 or higher;
1064+
* The `libcurl`_ package version 7.36 or higher, used with PHP >= 7.2.17 / 7.3.4;
10491065
* The `amphp/http-client`_ Packagist package version 4.2 or higher.
10501066

10511067
To force HTTP/2 for ``http`` URLs, you need to enable it explicitly via the
@@ -1095,9 +1111,9 @@ To force HTTP/2 for ``http`` URLs, you need to enable it explicitly via the
10951111
10961112
$client = HttpClient::create(['http_version' => '2.0']);
10971113
1098-
Support for HTTP/2 PUSH works out of the box when libcurl >= 7.61 is used with
1099-
PHP >= 7.2.17 / 7.3.4: pushed responses are put into a temporary cache and are
1100-
used when a subsequent request is triggered for the corresponding URLs.
1114+
Support for HTTP/2 PUSH works out of the box when using a compatible client:
1115+
pushed responses are put into a temporary cache and are used when a
1116+
subsequent request is triggered for the corresponding URLs.
11011117

11021118
Processing Responses
11031119
--------------------

0 commit comments

Comments
 (0)