Skip to content

Explain how to use Target attribute #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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