Skip to content

Commit

Permalink
improve plugin configuration example (#234)
Browse files Browse the repository at this point in the history
splitting up the examples for plugin configuration to make it easier to see what you can do
  • Loading branch information
dbu authored and Nyholm committed Oct 27, 2018
1 parent 008f425 commit 2e99696
Showing 1 changed file with 40 additions and 15 deletions.
55 changes: 40 additions & 15 deletions integrations/symfony-bundle.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,35 +224,26 @@ services are:
Plugins
```````

Clients can have plugins. Generic plugins from ``php-http/plugins`` (e.g. retry
or redirect) can be configured globally. You can tell the client which of those
plugins to use, as well as custom plugins that you configured a service for.
Clients can have plugins that act on the request before it is sent out and/or
on the response before it is returned to the caller. Generic plugins from
``php-http/client-common`` (e.g. retry or redirect) can be configured globally.
You can tell the client which of those plugins to use, as well as specify the
service names of custom plugins that you want to use.

Additionally you can configure any of the ``php-http/plugins`` specifically on
a client. For some plugins this is the only place where they can be configured.
The order in which you specify the plugins **does** matter.

.. code-block:: yaml
// services.yml
acme_plugin:
class: Acme\Plugin\MyCustomPlugin
arguments: ["%some_parameter%"]
Configure plugins directly on the client:

.. code-block:: yaml
// config.yml
httplug:
plugins:
cache:
cache_pool: 'my_cache_pool'
clients:
acme:
factory: 'httplug.factory.guzzle6'
plugins:
- 'acme_plugin'
- 'httplug.plugin.cache'
- 'httplug.plugin.retry'
- add_host:
host: "http://localhost:8000"
- header_defaults:
Expand All @@ -265,6 +256,40 @@ The order in which you specify the plugins **does** matter.
password: 'p4ssw0rd'
Configure the cache plugin globally and use it in the ``acme`` client:

.. code-block:: yaml
// config.yml
httplug:
plugins:
cache:
cache_pool: 'my_cache_pool'
clients:
acme:
factory: 'httplug.factory.guzzle6'
plugins:
- 'httplug.plugin.cache'
Configure a service for your custom plugin and use it in the client:

.. code-block:: yaml
// services.yml
acme_plugin:
class: Acme\Plugin\MyCustomPlugin
arguments: ["%some_parameter%"]
.. code-block:: yaml
// config.yml
httplug:
clients:
acme:
factory: 'httplug.factory.guzzle6'
plugins:
- 'acme_plugin'
Authentication
``````````````

Expand Down

0 comments on commit 2e99696

Please sign in to comment.