Skip to content

Commit d93e489

Browse files
authored
Explain how to use Target attribute (#287)
* Explain how to use `Target` attribute
1 parent 1a81e52 commit d93e489

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

integrations/symfony-bundle.rst

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ Usage
8787
$request = $this->container->get('httplug.message_factory')->createRequest('GET', 'http://example.com');
8888
$response = $this->container->get('httplug.client.acme')->sendRequest($request);
8989
90-
Autowiring the Default Client
91-
-----------------------------
90+
Autowiring
91+
----------
9292

9393
The first configured client is considered the "default" client. It is available
9494
for `autowiring`_ both for ``HttpClient`` and ``HttpAsyncClient``. This can be
@@ -103,6 +103,18 @@ Therefore you can disable autowiring with a configuration option:
103103
httplug:
104104
default_client_autowiring: false
105105
106+
When using this bundle with Symfony 5.3 or newer, you can use the `#[Target]` attribute to select a
107+
client by name:
108+
109+
.. code-block:: php
110+
111+
final class MyService
112+
{
113+
public function __construct(
114+
#[Target('acme')] HttpClient $client
115+
) {}
116+
}
117+
106118
Web Debug Toolbar
107119
`````````````````
108120
.. image:: /assets/img/debug-toolbar.png

0 commit comments

Comments
 (0)