@@ -84,15 +84,15 @@ Usage
84
84
85
85
.. code-block :: php
86
86
87
- $request = $this->container->get('httplug.message_factory ')->createRequest('GET', 'http://example.com');
87
+ $request = $this->container->get('httplug.psr17_request_factory ')->createRequest('GET', 'http://example.com');
88
88
$response = $this->container->get('httplug.client.acme')->sendRequest($request);
89
89
90
90
Autowiring
91
91
``````````
92
92
93
93
The first configured client is considered the "default" client. The default
94
94
clients are available for `autowiring `_: The PSR-18 ``Psr\Http\Client\ClientInterface ``
95
- (or the deprecated `` Http\Client\HttpClient ``) and the ``Http\Client\HttpAsyncClient ``.
95
+ and the ``Http\Client\HttpAsyncClient ``.
96
96
Autowiring can be convenient to build your application.
97
97
98
98
However, if you configured several different clients and need to be sure that
@@ -110,12 +110,13 @@ When using this bundle with Symfony 5.3 or newer, you can use the Symfony
110
110
111
111
.. code-block :: php
112
112
113
+ use Psr\Http\Client\ClientInterface;
113
114
use Symfony\Component\DependencyInjection\Attribute as DI;
114
115
115
116
final class MyService
116
117
{
117
118
public function __construct(
118
- #[DI\Target('acme')] HttpClient $client
119
+ #[DI\Target('acme')] ClientInterface $client
119
120
) {}
120
121
}
121
122
@@ -175,8 +176,8 @@ also disable the profiling by configuration.
175
176
You can configure the bundle to show debug information for clients found with
176
177
discovery. You may also force a specific client to be found when a third party
177
178
library is using discovery. The configuration below makes sure the client with
178
- service id ``httplug.client.my_guzzle5 `` is returned when calling
179
- ``HttpClientDiscovery ::find() `` . It does also make sure to show debug info for
179
+ service id ``httplug.client.my_guzzle7 `` is returned when calling
180
+ ``Psr18ClientDiscovery ::find() `` . It does also make sure to show debug info for
180
181
asynchronous clients.
181
182
182
183
.. note ::
@@ -187,10 +188,10 @@ asynchronous clients.
187
188
188
189
httplug :
189
190
clients :
190
- my_guzzle5 :
191
- factory : ' httplug.factory.guzzle5 '
191
+ my_guzzle7 :
192
+ factory : ' httplug.factory.guzzle7 '
192
193
discovery :
193
- client : ' httplug.client.my_guzzle5 '
194
+ client : ' httplug.client.my_guzzle7 '
194
195
async_client : ' auto'
195
196
196
197
For normal clients, the auto discovery debug info is enabled by default. For
@@ -211,10 +212,11 @@ example shows how you configure factory classes using Guzzle:
211
212
212
213
httplug :
213
214
classes :
214
- client : Http\Adapter\Guzzle6\Client
215
- message_factory : Http\Message\MessageFactory\GuzzleMessageFactory
216
- uri_factory : Http\Message\UriFactory\GuzzleUriFactory
217
- stream_factory : Http\Message\StreamFactory\GuzzleStreamFactory
215
+ client : Http\Adapter\Guzzle7\Client
216
+ psr17_request_factory : GuzzleHttp\Psr7\HttpFactory
217
+ psr17_response_factory : GuzzleHttp\Psr7\HttpFactory
218
+ psr17_uri_factory : GuzzleHttp\Psr7\HttpFactory
219
+ psr17_stream_factory : GuzzleHttp\Psr7\HttpFactory
218
220
219
221
Configure Clients
220
222
`````````````````
@@ -227,8 +229,8 @@ services.
227
229
228
230
httplug :
229
231
clients :
230
- my_guzzle5 :
231
- factory : ' httplug.factory.guzzle5 '
232
+ my_guzzle7 :
233
+ factory : ' httplug.factory.guzzle7 '
232
234
config :
233
235
# These options are given to Guzzle without validation.
234
236
defaults :
@@ -244,10 +246,10 @@ services.
244
246
245
247
.. code-block :: php
246
248
247
- $httpClient = $this->container->get('httplug.client.my_guzzle5 ');
249
+ $httpClient = $this->container->get('httplug.client.my_guzzle7 ');
248
250
$httpClient = $this->container->get('httplug.client.acme');
249
251
250
- // will be the same as ``httplug.client.my_guzzle5 ``
252
+ // will be the same as ``httplug.client.my_guzzle7 ``
251
253
$httpClient = $this->container->get('httplug.client');
252
254
253
255
The bundle has client factory services that you can use to build your client.
@@ -257,11 +259,11 @@ services are:
257
259
258
260
* ``httplug.factory.curl ``
259
261
* ``httplug.factory.buzz ``
260
- * ``httplug.factory.guzzle5 ``
261
262
* ``httplug.factory.guzzle6 ``
262
263
* ``httplug.factory.guzzle7 ``
263
264
* ``httplug.factory.react ``
264
265
* ``httplug.factory.socket ``
266
+ * ``httplug.factory.symfony ``
265
267
* ``httplug.factory.mock `` (Install ``php-http/mock-client `` first)
266
268
267
269
.. note ::
@@ -479,11 +481,13 @@ List of Services
479
481
+-------------------------------------+-------------------------------------------------------------------------+
480
482
| Service id | Description |
481
483
+=====================================+=========================================================================+
482
- | ``httplug.message_factory `` | Service* that provides the `Http\Message\MessageFactory ` |
484
+ | ``httplug.psr17_request_factory `` | Service* that provides the `Psr\ Http\Message\RequestFactoryInterface ` |
483
485
+-------------------------------------+-------------------------------------------------------------------------+
484
- | ``httplug.uri_factory `` | Service* that provides the `Http\Message\UriFactory ` |
486
+ | ``httplug.psr17_response_factory `` | Service* that provides the `Psr\ Http\Message\ResponseFactoryInterface ` |
485
487
+-------------------------------------+-------------------------------------------------------------------------+
486
- | ``httplug.stream_factory `` | Service* that provides the `Http\Message\StreamFactory ` |
488
+ | ``httplug.psr17_uri_factory `` | Service* that provides the `Psr\Http\Message\UriFactoryInterface ` |
489
+ +-------------------------------------+-------------------------------------------------------------------------+
490
+ | ``httplug.psr17_stream_factory `` | Service* that provides the `Psr\Http\Message\StreamFactoryInterface ` |
487
491
+-------------------------------------+-------------------------------------------------------------------------+
488
492
| ``httplug.client.[name] `` | There is one service per named client. |
489
493
+-------------------------------------+-------------------------------------------------------------------------+
0 commit comments