Skip to content

improve plugin configuration example #234

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 1 commit into from
Oct 27, 2018
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
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