Skip to content

Commit 2e99696

Browse files
dbuNyholm
authored andcommitted
improve plugin configuration example (#234)
splitting up the examples for plugin configuration to make it easier to see what you can do
1 parent 008f425 commit 2e99696

File tree

1 file changed

+40
-15
lines changed

1 file changed

+40
-15
lines changed

integrations/symfony-bundle.rst

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -224,35 +224,26 @@ services are:
224224
Plugins
225225
```````
226226

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

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

235-
.. code-block:: yaml
236-
237-
// services.yml
238-
acme_plugin:
239-
class: Acme\Plugin\MyCustomPlugin
240-
arguments: ["%some_parameter%"]
237+
Configure plugins directly on the client:
241238

242239
.. code-block:: yaml
243240
244241
// config.yml
245242
httplug:
246-
plugins:
247-
cache:
248-
cache_pool: 'my_cache_pool'
249243
clients:
250244
acme:
251245
factory: 'httplug.factory.guzzle6'
252246
plugins:
253-
- 'acme_plugin'
254-
- 'httplug.plugin.cache'
255-
- 'httplug.plugin.retry'
256247
- add_host:
257248
host: "http://localhost:8000"
258249
- header_defaults:
@@ -265,6 +256,40 @@ The order in which you specify the plugins **does** matter.
265256
password: 'p4ssw0rd'
266257
267258
259+
Configure the cache plugin globally and use it in the ``acme`` client:
260+
261+
.. code-block:: yaml
262+
263+
// config.yml
264+
httplug:
265+
plugins:
266+
cache:
267+
cache_pool: 'my_cache_pool'
268+
clients:
269+
acme:
270+
factory: 'httplug.factory.guzzle6'
271+
plugins:
272+
- 'httplug.plugin.cache'
273+
274+
Configure a service for your custom plugin and use it in the client:
275+
276+
.. code-block:: yaml
277+
278+
// services.yml
279+
acme_plugin:
280+
class: Acme\Plugin\MyCustomPlugin
281+
arguments: ["%some_parameter%"]
282+
283+
.. code-block:: yaml
284+
285+
// config.yml
286+
httplug:
287+
clients:
288+
acme:
289+
factory: 'httplug.factory.guzzle6'
290+
plugins:
291+
- 'acme_plugin'
292+
268293
Authentication
269294
``````````````
270295

0 commit comments

Comments
 (0)