Skip to content

Commit

Permalink
Explain how to use Target attribute (#287)
Browse files Browse the repository at this point in the history
* Explain how to use `Target` attribute
  • Loading branch information
ruudk committed Jul 10, 2021
1 parent 1a81e52 commit d93e489
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions integrations/symfony-bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ Usage
$request = $this->container->get('httplug.message_factory')->createRequest('GET', 'http://example.com');
$response = $this->container->get('httplug.client.acme')->sendRequest($request);
Autowiring the Default Client
-----------------------------
Autowiring
----------

The first configured client is considered the "default" client. It is available
for `autowiring`_ both for ``HttpClient`` and ``HttpAsyncClient``. This can be
Expand All @@ -103,6 +103,18 @@ Therefore you can disable autowiring with a configuration option:
httplug:
default_client_autowiring: false
When using this bundle with Symfony 5.3 or newer, you can use the `#[Target]` attribute to select a
client by name:

.. code-block:: php
final class MyService
{
public function __construct(
#[Target('acme')] HttpClient $client
) {}
}
Web Debug Toolbar
`````````````````
.. image:: /assets/img/debug-toolbar.png
Expand Down

0 comments on commit d93e489

Please sign in to comment.