chargebee / chargebee-php

PHP library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Chargebee 3.2.0-rc.1 doesn't work with Guzzle 7

scr4bble opened this issue · comments

Versions:

  • chargebee-php:3.2.0-rc.1
  • guzzlehttp/guzzle: "7.4.0"

Code triggering error:

$cb_subscriptions = ChargeBee_Subscription::all([
			"limit" => 100,
			"offset" => $offset,
			"sortBy[asc]" => "updated_at"
		]);

Stack trace:

PHP Fatal error:  Uncaught Error: Call to undefined method GuzzleHttp\\Utils::chooseHandler() in \/vendor\/guzzlehttp\/guzzle\/src\/functions.php:61
Stack trace:\n
#0 \/vendor\/guzzlehttp\/guzzle\/src\/HandlerStack.php(42): GuzzleHttp\\choose_handler()
#1 \/vendor\/guzzlehttp\/guzzle\/src\/Client.php(65): GuzzleHttp\\HandlerStack::create()
#2 \/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Guzzle.php(32): GuzzleHttp\\Client->__construct()
#3 \/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Guzzle.php(26): ChargeBee\\ChargeBee\\Guzzle::request('get', '\/subscriptions', Object(ChargeBee\\ChargeBee\\Environment), Array, Array)
#4 \/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Request.php(36): ChargeBee\\ChargeBee\\Guzzle::doRequest('get', '\/subscriptions', Object(ChargeBee\\ChargeBee\\Environment), Array, Array)
#5 \/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Request.php(22): ChargeBee\\ChargeBee\\Request::send('get', '\/subscriptions', Array, Object(ChargeBee\\ChargeBee\\Environment), Array)
#6 \/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Models\/Subscription.php(109): ChargeBee\\ChargeBee\\Request::sendListRequest('get', '\/subscriptions', Array, NULL, Array)
#7 \/chargebee.php(51): ChargeBee\\ChargeBee\\Models\\Subscription::all(Array)

@scr4bble - Looking at the error it seems somehow your code is still referring to old version of guzzle as chooseHandler() method is defined in the guzzle 7.4.0

#0 /vendor/guzzlehttp/guzzle/src/HandlerStack.php(42): GuzzleHttp\choose_handler()
this error shows in HandlerStack.php file somehow choose_handler() is there where it should be chooseHandler()

In guzzle < 7 choose_handler() method is defined
In guzzle > 7 chooseHandler() method is defined

You can try below things :

  1. Run composer update and verify in your vendor/guzzlehttp/guzzle/src/HandlerStack.php file
  2. If you are using other dependencies in your composer.json which is restricting you to upgrade to guzzle > 7.x then you can force install the guzzle version > 7.x

Let us know if these worked for you.

Thank you for the investigation. Composer update worked. We actually still had the old version of guzzle installed -_-
Cause of the problem - having multiple composer.json files in different parts of the project. Wasn't problem until now - we will need to unify that to eliminate such dependency versioning mess.

I am closing this - thank you for the help :)