Skip to content
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

Plugins #21

Closed
ghost opened this issue Sep 16, 2015 · 6 comments
Closed

Plugins #21

ghost opened this issue Sep 16, 2015 · 6 comments
Assignees

Comments

@ghost
Copy link

ghost commented Sep 16, 2015

I can't seem to find a way to addl handlers, plugins, Middleware or even add additional events to the guzzle package. I have a use-case where in I need to be able to change an authentication header, and I'd like to provide a plugin that can handle the work. However; I don't see how to make it work currently.

My initial thought was to try and add the plugin but I don't see how that is loaded. Then I tried to add it through a compiler pass; but since I don't have access to the options being set on the client I can't do that. My second thought was to create a handler on the guzzle stack, that would emit events, and then bind to handlers/listeners using tags.

Would this be something you where interested in?

@florianpreusner
Copy link
Member

Added handler stack as a service so you can now add your own middlewares/plugins.
You can get this version by setting the repo in composer.json:

"repositories": [
    {
        "url":  "https://github.com/florianpreusner/GuzzleBundle.git",
        "type": "git"
    }
],

"require": {    
    "eightpoints/guzzle-bundle": "dev-master"
}

After getting this version you should be able to get the guzzle handler stack by the container and add your own middlewares:

$stack = $this->get('guzzle.handler_stack.NAME_OF_CLIENT_BY_CONFIG');
$stack->push($callable);

Please check if that fits your request. If so I can integrate this change and also provide a documentation.

Best regards
Florian

@ghost
Copy link
Author

ghost commented Sep 19, 2015

I have a patch I've written that actually dispatches an event.

Sent from my iPhone

On Sep 19, 2015, at 6:08 PM, Florian Preusner notifications@github.com wrote:

Added handler stack as a service so you can now add your own middlewares/plugins.
You can get this version by setting the repo in composer.json:

"repositories": [
{
"url": "https://github.com/florianpreusner/GuzzleBundle.git",
"type": "git"
}
],

"require": {
"eightpoints/guzzle-bundle": "dev-master"
}
After getting this version you should be able to get the guzzle handler stack by the container and add your own middlewares:

$stack = $this->get('guzzle.handler_stack.NAME_OF_CLIENT_BY_CONFIG');
$stack->push($callable);
Please check if that fits your request. If so I can integrate this change and also provide a documentation.

Best regards
Florian


Reply to this email directly or view it on GitHub.

@florianpreusner
Copy link
Member

Can you share some more information cause your idea to be able to push middlewares to the handler stack seems to be interesting for others also.

@quadland quadland mentioned this issue Sep 21, 2015
@quadland
Copy link

@florianpreusner That pull request is the enhancement I spoke of.

Chris Warner

@florianpreusner
Copy link
Member

I see. Great! Thanks for your contribution, your PR is merged.

@MLKiiwy
Copy link

MLKiiwy commented May 18, 2016

Hello,

I try to add some middleware in my guzzle client, but your service id for handler doesn't exist anymore. And if I see your code your system that create handler is totally static we can't add handler ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants