Skip to content

Configure plugins clients with plugins #15

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

Closed
Nyholm opened this issue Jan 5, 2016 · 2 comments
Closed

Configure plugins clients with plugins #15

Nyholm opened this issue Jan 5, 2016 · 2 comments

Comments

@Nyholm
Copy link
Member

Nyholm commented Jan 5, 2016

Can I get some feedback on this approach to configure the plugins?

my_redirect_plugin:
  class: Http\Client\Plugin\RedirectPlugin 
my_logger_plugin:
  class: Http\Client\Plugin\LoggerPlugin 
  arguments: ["@monolog"]
my_cache_plugin:
  class: Http\Client\Plugin\CachePlugin 
  arguments: ["@cache", "@stream_factory"]

httplug:
  clients: 
    my_guzzle5: 
      factory: 'httplug.factory.guzzle5'
      plugins: ['@my_logger_plugin', '@my_cache_plugin']
      config:
        defaults:
          verify_ssl: false
          timeout: 4
    acme: 
      factory: 'httplug.factory.guzzle6'
      plugins: ['@my_logger_plugin', '@my_redirect_plugin']
      config:
        base_uri: 'http://google.se/'

This would allow you to use your own plugins, set the order etc. It would also be easy to inject a JournalPlugin to use internally for the debug toolbar.

We could go with an approach where we name the plugins etc etc but it is a simplier implementation and easier to use (no magic) if we reference them as a service.

@dbu
Copy link
Collaborator

dbu commented Jan 5, 2016

this looks simple and clean enough, i like it!

maybe we can provide default services for the plugins provided by php-http/plugin, if needed with options to configure things on them. but as with client factories, you would just use the full service name php_http.plugin.redirect (or similar) to add the plugin to a client, no shortcut that adds magic.

@Nyholm Nyholm mentioned this issue Jan 5, 2016
@Nyholm Nyholm changed the title Configure plugins Configure plugins clients with plugins Jan 6, 2016
@Nyholm
Copy link
Member Author

Nyholm commented Jan 8, 2016

Closed by #16

@Nyholm Nyholm closed this as completed Jan 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants