Skip to content

Commit fd617e3

Browse files
[HttpClient] make HttpClient::create() return an AmpHttpClient when amphp/http-client is found but curl is not or too old
1 parent 24b9fa4 commit fd617e3

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

http_client.rst

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -854,14 +854,26 @@ To leverage all these design benefits, the cURL extension is needed.
854854
Enabling cURL Support
855855
~~~~~~~~~~~~~~~~~~~~~
856856

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, `AmpHttpClient`_ 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 AmpHttpClient.
861+
862+
.. note::
863+
864+
To use the `AmpHttpClient`_, the `amphp/http-client`_ package must be
865+
installed.
866+
867+
.. versionadded:: 5.1
868+
869+
Integration with ``amphp/http-client`` was introduced in Symfony 5.1.
860870

861871
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::
865877

866878
use Symfony\Component\HttpClient\CurlHttpClient;
867879
use Symfony\Component\HttpClient\NativeHttpClient;
@@ -874,7 +886,7 @@ explicitly, use the following classes to create the client::
874886

875887
When using this component in a full-stack Symfony application, this behavior is
876888
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.
889+
is installed and enabled, and will fall back as explained above.
878890

879891
Configuring CurlHttpClient Options
880892
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -2055,3 +2067,4 @@ test it in a real application::
20552067
.. _`EventSource`: https://www.w3.org/TR/eventsource/#eventsource
20562068
.. _`idempotent method`: https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Idempotent_methods
20572069
.. _`SSRF`: https://portswigger.net/web-security/ssrf
2070+
.. _`AmpHttpClient`: https://github.com/amphp/http-client

0 commit comments

Comments
 (0)