@@ -975,15 +975,28 @@ To leverage all these design benefits, the cURL extension is needed.
975
975
Enabling cURL Support
976
976
~~~~~~~~~~~~~~~~~~~~~
977
977
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.
981
991
982
992
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::
986
998
999
+ use Symfony\Component\HttpClient\AmpHttpClient;
987
1000
use Symfony\Component\HttpClient\CurlHttpClient;
988
1001
use Symfony\Component\HttpClient\NativeHttpClient;
989
1002
@@ -993,9 +1006,12 @@ explicitly, use the following classes to create the client::
993
1006
// uses the cURL PHP extension
994
1007
$client = new CurlHttpClient();
995
1008
1009
+ // uses the client from the `amphp/http-client` package
1010
+ $client = new AmpHttpClient();
1011
+
996
1012
When using this component in a full-stack Symfony application, this behavior is
997
1013
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 .
999
1015
1000
1016
Configuring CurlHttpClient Options
1001
1017
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1045,7 +1061,7 @@ HTTP/2 Support
1045
1061
When requesting an ``https `` URL, HTTP/2 is enabled by default if one of the
1046
1062
following tools is installed:
1047
1063
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 ;
1049
1065
* The `amphp/http-client `_ Packagist package version 4.2 or higher.
1050
1066
1051
1067
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
1095
1111
1096
1112
$client = HttpClient::create(['http_version' => '2.0']);
1097
1113
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.
1101
1117
1102
1118
Processing Responses
1103
1119
--------------------
0 commit comments