PHP cannot find the GuzzleHttp\Client class
Class 'GuzzleHttp\Client' not foundShort answer
PHP only knows GuzzleHttp\Client when the Guzzle package is installed and Composer's autoloader is loaded. Run composer require guzzlehttp/guzzle, make sure vendor/ exists on the server (composer install), and in plain PHP scripts load vendor/autoload.php before you use the class.
Fix it fast
1Find out which cause you have
Ask Composer whether Guzzle is part of this project and whether the vendor folder holds it.
composer show guzzlehttp/guzzle ls vendor/guzzlehttp2Match what you see, then jump to its fix
- 1
composer show says the package is not installed, and vendor/guzzlehttp does not existThe Guzzle package is not required by the projectFix - 2
composer.json and composer.lock list guzzlehttp/guzzle, but vendor/guzzlehttp is absentThe vendor folder is missing or out of date on this serverFix - 3
The error comes from a plain .php file run outside Laravel, and vendor/guzzlehttp existsA standalone PHP script never loads Composer's autoloaderFix
- 1
What does the error look like?
Class 'GuzzleHttp\Client' not foundClass "GuzzleHttp\Client" not found
Cause 1 of 3
The Guzzle package is not required by the project
1Check
Guzzle is a separate package. The code imports it, but composer.json does not list it.
grep -n guzzlehttp composer.json2Fix
Add it with Composer; this writes it to composer.json and installs it.
composer require guzzlehttp/guzzle:^7.03Verify
Composer now shows the package, and the class loads.
composer show guzzlehttp/guzzleConfirmed by docs.guzzlephp.org
Cause 2 of 3
The vendor folder is missing or out of date on this server
1Check
vendor/ is usually not committed. After a deploy or clone, the packages must be installed from composer.lock.
grep -c guzzlehttp composer.lock; ls vendor | head2Fix
Run install, which reads composer.lock, fills vendor and builds the autoloader. On production add --no-dev.
composer install --no-dev3Verify
The folder now exists.
ls vendor/guzzlehttpConfirmed by getcomposer.org
Cause 3 of 3
A standalone PHP script never loads Composer's autoloader
1Check
Laravel loads vendor/autoload.php for you. A script run on its own has to do it.
grep -n "autoload.php" script.php2Fix
Require the autoloader at the top of the script, before the first use of the class.
<?php
require __DIR__ . '/vendor/autoload.php';
$client = new GuzzleHttp\Client();3Verify
Run the script again.
php script.phpConfirmed by docs.guzzlephp.org
How do I stop it coming back?
- Require every package your code imports, directly, in composer.json.
- Commit composer.lock and run composer install as a fixed step of each deploy.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Back end
Composer says the gd extension is missing on a Laravel project
composer install or composer update stops on a package that requires ext-gd
Composer refuses to install a package that requires ext-gd when the PHP binary running Composer has no GD extension.
4 causes, each with a fixBack end
composer require maatwebsite/excel fails to install
Composer says the package needs an older PHP than the one installed
Composer refuses maatwebsite/excel when the PHP version or a PHP extension does not match what the package and PhpSpreadsheet need.
3 causes, each with a fixBack end
composer install says the lock file is not compatible and asks for update
Your lock file does not contain a compatible set of packages. Please run composer update.
composer install checked the locked packages against this machine's PHP and extensions and found a conflict.
3 causes, each with a fixBack end
composer require laravel/horizon fails: ext-pcntl is missing
laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system
Horizon needs the pcntl extension, and Composer refuses to install it where PHP lacks that extension.
3 causes, each with a fixBack end
composer require laravel/passport stops with 'requirements could not be resolved'
... but these were not loaded, likely because it conflicts with another require.
Composer found no Passport release that fits your project at once.
4 causes, each with a fixBack end
Composer says the root composer.json requires a PHP version your PHP does not satisfy
Your requirements could not be resolved to an installable set of packages.
Composer compares the php constraint in your composer.json, or in a package, with the PHP that runs Composer.
3 causes, each with a fix