Antony Leme
Antony Leme

Reputation: 231

Call to undefined method GuzzleHttp\Utils::chooseHandler() when sending email

My application was working fine and when I woke up today i faced this error:

Call to undefined method GuzzleHttp\Utils::chooseHandler(

/opt/bitnami/apache/htdocs/php/plain/vendor/guzzlehttp/guzzle/src/HandlerStack.php:42

function choose_handler(): callable
    
    {
    
        return Utils::chooseHandler();
    
    }

This is when the error happens:

Mail::to($request->email)->send(new ProfessionalInvited($clinic, $person, $inviteId));

What could happened? And what should I do? I already tried deleting my vendor and composer.lock and reinstall everything. But without success. I was also having this error in API calls using guzzle and when I changed to cURL everything worked fine. But I dont think I can do the same to send emails since Guzzle is a dependency.

Upvotes: 5

Views: 10865

Answers (2)

Cedric Anamorphik
Cedric Anamorphik

Reputation: 71

I ran into the same problem developing a WordPress plugin with a Guzzle dependency. The issue was another plugin using a different version of Guzzle.

See also "MAJOR_VERSION undefined class constant in src/utils.php": https://github.com/guzzle/guzzle/issues/2744

Upvotes: 0

Marcin Nabiałek
Marcin Nabiałek

Reputation: 111839

Hard to say what exactly happened but I can guess:

  1. You installed wrong Guzzle version and it does not have chooseHandler method in Utils class (or it was reinstalled somehow on server).
  2. Somehow file was removed
  3. There was some problem with composer and you should run composer dump-autoload

I verified it and this method and class exists in Guzzle 7.x version and it's also mentioned in documentation.

Upvotes: 0

Related Questions