Skip to content

Commit

Permalink
Merge pull request #260 from php-http/autowire
Browse files Browse the repository at this point in the history
document autowiring and disabling it
  • Loading branch information
dbu committed Mar 21, 2019
2 parents 3009191 + 1099997 commit 846dadd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
16 changes: 16 additions & 0 deletions integrations/symfony-bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ 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
-----------------------------

The first configured client is considered the "default" client. It is available
for `autowiring`_ both for ``HttpClient`` and ``HttpAsyncClient``. This can be
convenient to build your application.

However, if you configured several different clients and need to be sure that
the correct client is used in each service, it can also hide mistakes.
Therefore you can disable autowiring with a configuration option:

.. code-block:: yaml
httplug:
default_client_autowiring: false
Web Debug Toolbar
`````````````````
Expand Down Expand Up @@ -444,3 +459,4 @@ To mock a response in your tests, do:
<div style="clear:left"></div>

.. _`Symfony Flex`: https://symfony.com/doc/current/setup/flex.html
.. _`autowiring`: https://symfony.com/doc/current/service_container/autowiring.html
4 changes: 4 additions & 0 deletions integrations/symfony-full-configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ This page shows an example of all configuration values provided by the bundle.
// config.yml
httplug:
# allows to disable autowiring of the clients
default_client_autowiring: true
# define which service to use as httplug.<type>
# this does NOT change autowiring, which will always go to the "default" client
main_alias:
client: httplug.client.default
message_factory: httplug.message_factory.default
Expand Down

0 comments on commit 846dadd

Please sign in to comment.