-1

I've been reading answers from all the questions related to GuzzleHttp\Client but situation is getting worst. I am trying to send E-mail Updates to all of my Application users using Laravel Queues. I don't know what's wrong but Jobs are failing.

I am properly caching the Exceptions and reporting them to laravel.log file. Here is what I am getting when I try to execute queue worker.

[2018-03-23 11:43:06] production.ERROR: Class 'GuzzleHttp\Client' not found {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Class 'GuzzleHttp\\Client' not found at /home/polymath/saio/public_html/vendor/laravel/framework/src/Illuminate/Mail/TransportManager.php:181)

I've already installed GuzzleHttp\Client using composer require guzzlehttp/guzzle. It is successfully installed but still, I am getting the same error.

Even I tried to delete the current application files and clone my whole repository again. Still Facing the same issue. I even tried to clear caches using php artisan cache:clear , php artisan cache:config and php artisan clear-compiled(This made my whole application crash) , php artisan dump-autoload.

I can't find what's wrong but that's all logs say.

Adarsh Sojitra
  • 2,059
  • 1
  • 27
  • 50
  • 2
    Post the code where you are using it. And btw, are you `use`ing it at the top of your file? – brombeer Mar 23 '18 at 09:29
  • I am not using this package all on my own. I am just trying to send emails. Maybe Laravel needs this package. That's why I installed it. – Adarsh Sojitra Mar 23 '18 at 09:31
  • Oh, ok, I get it now. Make sure it's in your `composer.json` file. `php artisan cache:config` and `php artisan dump-autoload` don't exist, but that might just be typos. Use `php artisan config:clear` and `composer du`. See if you can [send a simple mail](https://laravel.com/docs/5.6/mail#sending-mail) (without using Queues). Other than that I can't help, sorry – brombeer Mar 23 '18 at 09:46
  • Yes. I can send a simple mail. – Adarsh Sojitra Mar 23 '18 at 10:15
  • Have you tried `composer dump-autoload` instead which will update autoload_classmap.php with newly added classes. – HelloSpeakman Mar 23 '18 at 10:22
  • Yes. I just tried `composer dump-autoload` but no, It's still the same. – Adarsh Sojitra Mar 23 '18 at 10:23
  • Can you test it in one of your controllers? `(new \GuzzleHttp\Client())->get('https://www.google.com')` – Jonas Staudenmeir Mar 23 '18 at 13:54

2 Answers2

0

It seems you may need an older version of Guzzle to work with Laravel, try using Guzzle 3.x by updating your composer.json like such

"guzzlehttp/guzzle": "~3"

If you wish you can also try to use ~4 and see if Guzzle 4.x will work for you, remember to run composer update and composer dump-autoload after updating your composer.json file.

Update: This info is based on research since Laravel 4 and may be deprecated for Laravel 5.x

HelloSpeakman
  • 810
  • 9
  • 22
0
use GuzzleHttp\Client;

in your method Add

$client = new Client();
  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 29 '21 at 10:23