Skip to content
Advertisement

What’s the equivalent of GuzzleHttpEventSubscriberInterface in Guzzle 6?

In Guzzle 5.3 you can use event subscribers as in the following example:

JavaScript

What would be the equivalent example in Guzzle 6?

As I’ve phpunit tests which are using onBefore/onComplete and onError event subscribers and the files needs to be upgraded.

Advertisement

Answer

In Guzzle 6 you must add your event class / functions like this:

JavaScript

and you class should look like this:

JavaScript

You can read this in UPGRADING.md from Guzzle.

Read guzzly options to understand what you can do with $options.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement