@@ -12,12 +12,16 @@ Client Interfaces
12
12
13
13
HTTPlug defines two HTTP client interfaces that we kept as simple as possible:
14
14
15
- * ``HttpClient `` defines a ``sendRequest `` method that sends a PSR-7
16
- ``RequestInterface `` and either returns a PSR-7 ``ResponseInterface `` or
17
- throws an exception that implements ``Http\Client\Exception ``.
15
+ * PSR-18 defines the ``ClientInterface `` with a ``sendRequest `` method that
16
+ accepts a PSR-7 ``RequestInterface `` and either returns a PSR-7
17
+ ``ResponseInterface `` or throws an exception that implements
18
+ ``Psr\Http\Client\ClientExceptionInterface ``.
18
19
19
- * ``HttpAsyncClient `` defines a ``sendAsyncRequest `` method that sends a request
20
- asynchronously and always returns a ``Http\Client\Promise ``.
20
+ HTTPlug has the compatible interface ``HttpClient `` which now extends the
21
+ PSR-18 interface to allow migrating to PSR-18.
22
+
23
+ * ``HttpAsyncClient `` defines a ``sendAsyncRequest `` method that sends a PSR-7
24
+ request asynchronously and always returns a ``Http\Client\Promise ``.
21
25
See :doc: `../components/promise ` for more information.
22
26
23
27
Implementations
@@ -29,16 +33,22 @@ PHP-HTTP offers two types of clients that implement the above interfaces:
29
33
30
34
Examples: :doc: `/clients/curl-client ` and :doc: `/clients/socket-client `.
31
35
32
- 2. Adapters that wrap existing HTTP client , such as Guzzle. These adapters act
36
+ 2. Adapters that wrap existing HTTP clients , such as Guzzle. These adapters act
33
37
as a bridge between the HTTPlug interfaces and the clients that do not (yet)
34
38
implement these interfaces.
35
39
36
- Examples: :doc: `/clients/guzzle6-adapter ` and :doc: `/clients/react-adapter `.
40
+ More and more clients implement PSR-18 directly. If that is all you need, we
41
+ recommend not using HTTPlug as it would only add overhead. However, as there
42
+ is no PSR for asynchronous requests yet, you can use the adapters to do such
43
+ requests without binding yourself to a specific implementation.
44
+
45
+ Examples: :doc: `/clients/guzzle7-adapter ` and :doc: `/clients/react-adapter `.
37
46
38
47
.. note ::
39
48
40
- Ideally, all HTTP client libraries out there will implement the HTTPlug
41
- interfaces. At that point, our adapters will no longer be necessary.
49
+ Ideally, there will be a PSR for asynchronous requests and all HTTP client
50
+ libraries out there will implement PSR-18 and the not yet existing PSR. At
51
+ that point, our adapters will no longer be necessary.
42
52
43
53
Usage
44
54
-----
0 commit comments