@@ -854,15 +854,28 @@ To leverage all these design benefits, the cURL extension is needed.
854
854
Enabling cURL Support
855
855
~~~~~~~~~~~~~~~~~~~~~
856
856
857
- This component supports both the native PHP streams and cURL to make the HTTP
858
- requests. Although both are interchangeable and provide the same features,
859
- including concurrent requests, HTTP/2 is only supported when using cURL.
857
+ This component supports the native PHP streams, ``amphp/http-client `` and cURL to
858
+ make the HTTP requests. Although they are interchangeable and provide the
859
+ same features, including concurrent requests, HTTP/2 is only supported when
860
+ using cURL or ``amphp/http-client ``.
861
+
862
+ .. note ::
863
+
864
+ To use the :class: `Symfony\\ Component\\ HttpClient\\ AmpHttpClient `, the
865
+ `amphp/http-client `_ package must be installed.
866
+
867
+ .. versionadded :: 5.1
868
+
869
+ Integration with ``amphp/http-client `` was introduced in Symfony 5.1.
860
870
861
871
The :method: `Symfony\\ Component\\ HttpClient\\ HttpClient::create ` method
862
- selects the cURL transport if the `cURL PHP extension `_ is enabled and falls
863
- back to PHP streams otherwise. If you prefer to select the transport
864
- explicitly, use the following classes to create the client::
872
+ selects the cURL transport if the `cURL PHP extension `_ is enabled. It falls
873
+ back to ``AmpHttpClient `` if cURL couldn't be found or is too old. Finally, if
874
+ ``AmpHttpClient `` is not available, it falls back to PHP streams.
875
+ If you prefer to select the transport explicitly, use the following classes
876
+ to create the client::
865
877
878
+ use Symfony\Component\HttpClient\AmpHttpClient;
866
879
use Symfony\Component\HttpClient\CurlHttpClient;
867
880
use Symfony\Component\HttpClient\NativeHttpClient;
868
881
@@ -872,9 +885,12 @@ explicitly, use the following classes to create the client::
872
885
// uses the cURL PHP extension
873
886
$client = new CurlHttpClient();
874
887
888
+ // uses the client from the `amphp/http-client` package
889
+ $client = new AmpHttpClient();
890
+
875
891
When using this component in a full-stack Symfony application, this behavior is
876
892
not configurable and cURL will be used automatically if the cURL PHP extension
877
- is installed and enabled. Otherwise, the native PHP streams will be used .
893
+ is installed and enabled, and will fall back as explained above .
878
894
879
895
Configuring CurlHttpClient Options
880
896
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -928,7 +944,7 @@ HTTP/2 Support
928
944
When requesting an ``https `` URL, HTTP/2 is enabled by default if one of the
929
945
following tools is installed:
930
946
931
- * The `libcurl `_ package version 7.36 or higher;
947
+ * The `libcurl `_ package version 7.36 or higher, used with PHP >= 7.2.17 / 7.3.4 ;
932
948
* The `amphp/http-client `_ Packagist package version 4.2 or higher.
933
949
934
950
.. versionadded :: 5.1
@@ -984,9 +1000,9 @@ To force HTTP/2 for ``http`` URLs, you need to enable it explicitly via the
984
1000
985
1001
$client = HttpClient::create(['http_version' => '2.0']);
986
1002
987
- Support for HTTP/2 PUSH works out of the box when libcurl >= 7.61 is used with
988
- PHP >= 7.2.17 / 7.3.4: pushed responses are put into a temporary cache and are
989
- used when a subsequent request is triggered for the corresponding URLs.
1003
+ Support for HTTP/2 PUSH works out of the box when using a compatible client:
1004
+ pushed responses are put into a temporary cache and are used when a
1005
+ subsequent request is triggered for the corresponding URLs.
990
1006
991
1007
Processing Responses
992
1008
--------------------
0 commit comments