@@ -88,11 +88,12 @@ Usage
8888 $response = $this->container->get('httplug.client.acme')->sendRequest($request);
8989
9090 Autowiring
91- ----------
91+ ``````````
9292
93- The first configured client is considered the "default" client. It is available
94- for `autowiring `_ both for ``HttpClient `` and ``HttpAsyncClient ``. This can be
95- convenient to build your application.
93+ The first configured client is considered the "default" client. The default
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 ``.
96+ Autowiring can be convenient to build your application.
9697
9798However, if you configured several different clients and need to be sure that
9899the correct client is used in each service, it can also hide mistakes.
@@ -103,15 +104,18 @@ Therefore you can disable autowiring with a configuration option:
103104 httplug :
104105 default_client_autowiring : false
105106
106- When using this bundle with Symfony 5.3 or newer, you can use the `#[Target] ` attribute to select a
107- client by name:
107+ When using this bundle with Symfony 5.3 or newer, you can use the Symfony
108+ `#[Target] ` attribute to select a client by name. For a client configured as
109+ ``httplug.clients.acme ``, this would be:
108110
109111.. code-block :: php
110112
113+ use Symfony\Component\DependencyInjection\Attribute as DI;
114+
111115 final class MyService
112116 {
113117 public function __construct(
114- #[Target('acme')] HttpClient $client
118+ #[DI\ Target('acme')] HttpClient $client
115119 ) {}
116120 }
117121
@@ -255,6 +259,7 @@ services are:
255259* ``httplug.factory.buzz ``
256260* ``httplug.factory.guzzle5 ``
257261* ``httplug.factory.guzzle6 ``
262+ * ``httplug.factory.guzzle7 ``
258263* ``httplug.factory.react ``
259264* ``httplug.factory.socket ``
260265* ``httplug.factory.mock `` (Install ``php-http/mock-client `` first)
@@ -312,6 +317,15 @@ Additionally you can configure any of the ``php-http/plugins`` specifically on
312317a client. For some plugins this is the only place where they can be configured.
313318The order in which you specify the plugins **does ** matter.
314319
320+ See :doc: `the plugin documentation <../plugins/index >` for more information on
321+ the plugins.
322+
323+ See :doc: `full configuration </integrations/symfony-full-configuration >` for
324+ the full list of plugins you can configure through this bundle. If a plugin is
325+ not available in the configuration, you can configure it as a service and
326+ reference the plugin by service id as you would do for a
327+ :ref: `custom plugin <symfony_custom_plugin >`.
328+
315329You can configure many of the plugins directly on the client:
316330
317331.. code-block :: yaml
@@ -335,10 +349,6 @@ You can configure many of the plugins directly on the client:
335349 username : ' my_username'
336350 password : ' p4ssw0rd'
337351
338-
339- See :doc: `full configuration </integrations/symfony-full-configuration >` for
340- the full list of plugins you can configure.
341-
342352 Alternatively, the same configuration also works on a global level. With this,
343353you can configure plugins once and then use them in several clients. The plugin
344354service names follow the pattern ``httplug.plugin.<name> ``:
@@ -364,6 +374,11 @@ service names follow the pattern ``httplug.plugin.<name>``:
364374 To configure HTTP caching, you need to require ``php-http/cache-plugin `` in
365375 your project. It is available as a separate composer package.
366376
377+ .. _symfony_custom_plugin :
378+
379+ Configure a Custom Plugin
380+ -------------------------
381+
367382To use a custom plugin or when you need specific configuration that is not
368383covered by the bundle configuration, you can configure the plugin as a normal
369384Symfony service and then reference that service name in the plugin list of your
@@ -387,7 +402,7 @@ client:
387402 - ' acme_plugin'
388403
389404 Authentication
390- ``````````````
405+ --------------
391406
392407You can configure a client with authentication. Valid authentication types are
393408``basic ``, ``bearer ``, ``service ``, ``wsse `` and ``query_param ``. See more examples at the
@@ -415,7 +430,7 @@ You can configure a client with authentication. Valid authentication types are
415430 The auth params will appear on the URL and we recommend to NOT log your request, especially on production side.
416431
417432VCR Plugin
418- ``````````
433+ ----------
419434
420435The :doc: `VCR Plugin </plugins/vcr >` allows to record and/or replay HTTP requests. You can configure the mode you want,
421436how to find recorded responses and how to match requests with responses. The mandatory options are:
@@ -549,6 +564,9 @@ To mock a response in your tests, do:
549564 If you do not specify the factory in your configuration, you can also directly
550565overwrite the httplug services:
551566
567+
568+ .. code-block :: yaml
569+
552570 # config/services_test.yaml
553571 services :
554572 # overwrite the http clients for mocking
0 commit comments