Closed kobelobster closed 7 years ago
True, handler
is not part of the container (anymore). This is nothing that was planned.
I will take a look into this today evening. Let's see if we can find a nice solution.
@tzfrs
You can access the handler (after creating the client) by using following function:
$client->getConfig('handler')->push(CLOSURE);
By this command you should be able to register your own middlewares.
This should also work in service configuration.
Please let me know if that works like expected. If so, I can add some more information in README.md.
I think this would work, however this would mean, I cannot register any middleware via compiler pass or with tags, since I'm not able to get a service via CompilerPass, but only the definition. I think the problem is that the client gets generated in the Extension
and not in the CompilerPass.
Ok, got it. Let me check that.
Is this the current way to register middlewares?
@thasmo @tzfrs I think PR #129 will resolve this problem. I described there https://github.com/8p/GuzzleBundle/issues/90#issuecomment-338002511 how to register custom middleware.
@gregurco Thanks for the update, but we couldn't wait that long and decided to create our own bundle. Thanks for your effort though!
@tzfrs Just to make sure to understand you correctly: Instead of contributing to an existing open source project you've created your own copy of this bundle? And in this bundle you "fixed" your mentioned issues? Sad story.
Why yet another Guzzle Bundle? We simply weren't happy with the code quality and middleware integration of existing bundles and our issues were not addressed by their maintainers.
Not addressed by their maintainers? Code quality? Do you understand what open source is? You are very welcome to make things better - this is how open source works. But by copying other things you should be aware that you are creating just more construction zones. I'm Just saying.
@florianpreusner Fragmentation is never nice, we are aware of that. That's why we linked xkcd in our readme file at the location you quoted. This aside, I cannot follow your arguments regarding open source. Our contribution to make things better is that we released a complete Guzzle bundle rewrite that meets our needs and that was paid for by our company, as open source software and free of charge.
Hi,
I want to have a middleware which will be used on every request. That's why I want to set the definition for that in my
BundleExtension
class. However, I don't seem to get it working.In the issue #21 you said to call
$stack = $this->get('guzzle.handler_stack.NAME_OF_CLIENT_BY_CONFIG');
to get the handler and then add the middleware by using thepush
method, or in my case, usingaddMethodCall
to add the push.However, the
handler_stack
doesn't seem to exist anymore and if I saw that correctly you are adding the middlewares to the handler and to the client when creating it, since the option to add handlers to a client is only present in the constructor. But how would I add a custom middleware? Or would I need to write a Client which extends your Client and do my configuration there?