@@ -224,35 +224,26 @@ services are:
224
224
Plugins
225
225
```````
226
226
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.
230
232
231
233
Additionally you can configure any of the ``php-http/plugins `` specifically on
232
234
a client. For some plugins this is the only place where they can be configured.
233
235
The order in which you specify the plugins **does ** matter.
234
236
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:
241
238
242
239
.. code-block :: yaml
243
240
244
241
// config.yml
245
242
httplug :
246
- plugins :
247
- cache :
248
- cache_pool : ' my_cache_pool'
249
243
clients :
250
244
acme :
251
245
factory : ' httplug.factory.guzzle6'
252
246
plugins :
253
- - ' acme_plugin'
254
- - ' httplug.plugin.cache'
255
- - ' httplug.plugin.retry'
256
247
- add_host :
257
248
host : " http://localhost:8000"
258
249
- header_defaults :
@@ -265,6 +256,40 @@ The order in which you specify the plugins **does** matter.
265
256
password : ' p4ssw0rd'
266
257
267
258
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
+
268
293
Authentication
269
294
``````````````
270
295
0 commit comments