From bf03c8ee5cdbc8b94e721076848cc721fc03882a Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Sat, 10 Jul 2021 09:37:20 +0200 Subject: [PATCH 1/3] Explain how to use `Target` attribute --- integrations/symfony-bundle.rst | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/integrations/symfony-bundle.rst b/integrations/symfony-bundle.rst index e868e76..8388ec6 100644 --- a/integrations/symfony-bundle.rst +++ b/integrations/symfony-bundle.rst @@ -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 @@ -103,6 +103,18 @@ Therefore you can disable autowiring with a configuration option: httplug: default_client_autowiring: false +With Symfony 5.3 it's possible to use the `#[Target]` attribute to select the +correct client: + +.. code-block:: php + + final class MyService + { + public function __construct( + #[Target('acme')] HttpClient $client + ) {} + } + Web Debug Toolbar ````````````````` .. image:: /assets/img/debug-toolbar.png From 1d7eddef5d4134c738c5edd9e3afd92fe7b86db3 Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Sat, 10 Jul 2021 18:05:04 +0200 Subject: [PATCH 2/3] Update integrations/symfony-bundle.rst Co-authored-by: David Buchmann --- integrations/symfony-bundle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/symfony-bundle.rst b/integrations/symfony-bundle.rst index 8388ec6..36bb8a1 100644 --- a/integrations/symfony-bundle.rst +++ b/integrations/symfony-bundle.rst @@ -104,7 +104,7 @@ Therefore you can disable autowiring with a configuration option: default_client_autowiring: false With Symfony 5.3 it's possible to use the `#[Target]` attribute to select the -correct client: +client by name: .. code-block:: php From 2a8c0065196003888ece0644e02a55cce987f2bf Mon Sep 17 00:00:00 2001 From: Ruud Kamphuis Date: Sat, 10 Jul 2021 18:05:27 +0200 Subject: [PATCH 3/3] Update integrations/symfony-bundle.rst Co-authored-by: David Buchmann --- integrations/symfony-bundle.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integrations/symfony-bundle.rst b/integrations/symfony-bundle.rst index 36bb8a1..90e39a0 100644 --- a/integrations/symfony-bundle.rst +++ b/integrations/symfony-bundle.rst @@ -103,7 +103,7 @@ Therefore you can disable autowiring with a configuration option: httplug: default_client_autowiring: false -With Symfony 5.3 it's possible to use the `#[Target]` attribute to select the +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