Laravel 6: FatalThrowableError: Class ‘GuzzleHttp\Client’ not found in TransportManager.php

huangapple go评论76阅读模式
英文:

Laravel 6: FatalThrowableError: Class 'GuzzleHttp\Client' not found in TransportManager.php

问题

I just updated my application to Laravel 6.
我刚刚将我的应用程序升级到 Laravel 6。

I'm sending email via Mailgun, and in my local environment I've confirmed that everything works perfectly.
我通过 Mailgun 发送电子邮件,在本地环境中,我确认一切正常运行。

But in staging I get the following error:
但在预发布环境中,我遇到以下错误:

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'GuzzleHttp\Client' not found in /my/directory/laravel/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php:193
Symfony\Component\Debug\Exception\FatalThrowableError: 类 'GuzzleHttp\Client' 未找到于 /my/directory/laravel/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php:193

I've run composer require guzzlehttp/guzzle and triple-checked that it is in the vendor folder and the autoload files on my staging server.
我运行了 composer require guzzlehttp/guzzle 并仔细检查了它是否在我的预发布服务器的 vendor 文件夹和 autoload 文件中。

My emails are sent over a queue. I called Guzzle from a controller method and it was found without problems, but for some reason when the queue job runs, the TransportManager can't access it.
我的电子邮件通过队列发送。我从控制器方法中调用了 Guzzle,并且没有问题,但是由于某种原因,当队列作业运行时,TransportManager 无法访问它。

Again, in my local homestead environment emails are sent via mailgun with no errors.
再次强调,在我的本地 Homestead 环境中,通过 Mailgun 发送电子邮件时没有错误。

I've done artisan cache:clear and artisan config:clear.
我已经运行了 artisan cache:clearartisan config:clear

I can't think of anything else to try. Any idea what could be causing the problem?
我想不出还有什么可以尝试的。您有任何想法可能是什么导致了这个问题?

英文:

I just updated my application to Laravel 6.

I'm sending email via Mailgun, and in my local environment I've confirmed that everything works perfectly.

But in staging I get the following error:

Symfony\Component\Debug\Exception\FatalThrowableError: Class 'GuzzleHttp\Client' not found in /my/directory/laravel/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php:193

I've run composer require guzzlehttp/guzzle and triple-checked that it is in the vendor folder and the autoload files on my staging server.

My emails are sent over a queue. I called Guzzle from a controller method and it was found without problems, but for some reason when the queue job runs, the TransportManager can't access it.

Again, in my local homestead environment emails are sent via mailgun with no errors.

I've done artisan cache:clear and artisan config:clear.

I can't think of anything else to try. Any idea what could be causing the problem?

答案1

得分: 2

I figured it out... Laravel queues use some code-caching magic I wasn't aware of. So my queue was using old code from before I ran composer require guzzlehttp/guzzle.

To solve the problem I had to run php artisan queue:restart.

Then I waited for my scheduler to rerun php artisan queue:work and my email is now sent as expected.

英文:

Figured it out... Laravel queues use some code-caching magic I wasn't aware of. So my queue was using old code from before I ran composer require guzzlehttp/guzzle.

To solve the problem I had to run php artisan queue:restart.

Then I waited for my scheduler to rerun php artisan queue:work and my email is now sent as expected.

huangapple
  • 本文由 发表于 2020年1月4日 00:05:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/59581688.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定