Skip to content

Commit 846dadd

Browse files
authored
Merge pull request #260 from php-http/autowire
document autowiring and disabling it
2 parents 3009191 + 1099997 commit 846dadd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

integrations/symfony-bundle.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,21 @@ Usage
6868
$request = $this->container->get('httplug.message_factory')->createRequest('GET', 'http://example.com');
6969
$response = $this->container->get('httplug.client.acme')->sendRequest($request);
7070
71+
Autowiring the Default Client
72+
-----------------------------
73+
74+
The first configured client is considered the "default" client. It is available
75+
for `autowiring`_ both for ``HttpClient`` and ``HttpAsyncClient``. This can be
76+
convenient to build your application.
77+
78+
However, if you configured several different clients and need to be sure that
79+
the correct client is used in each service, it can also hide mistakes.
80+
Therefore you can disable autowiring with a configuration option:
81+
82+
.. code-block:: yaml
83+
84+
httplug:
85+
default_client_autowiring: false
7186
7287
Web Debug Toolbar
7388
`````````````````
@@ -444,3 +459,4 @@ To mock a response in your tests, do:
444459
<div style="clear:left"></div>
445460

446461
.. _`Symfony Flex`: https://symfony.com/doc/current/setup/flex.html
462+
.. _`autowiring`: https://symfony.com/doc/current/service_container/autowiring.html

integrations/symfony-full-configuration.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ This page shows an example of all configuration values provided by the bundle.
77
88
// config.yml
99
httplug:
10+
# allows to disable autowiring of the clients
11+
default_client_autowiring: true
12+
# define which service to use as httplug.<type>
13+
# this does NOT change autowiring, which will always go to the "default" client
1014
main_alias:
1115
client: httplug.client.default
1216
message_factory: httplug.message_factory.default

0 commit comments

Comments
 (0)