Since Guzzle is a universal PHP package that was not specifically created for Laravel , so Laravel users are a little confused because you cannot use the class function statically.
To install and use Guzzle in Laravel 5 (I use it in Laravel 5.7),
composer require guzzlehttp/guzzle
Then you should see the guzzlehttp folder in the vendor folder.
To use it, you can
use GuzzleHttp\Exception\GuzzleException; use GuzzleHttp\Client as GuzzleClient; ... public function testGuzzle() { $client = new GuzzleClient(); ... }
If you do not want to import the namespace, you can also use it directly, as shown below
$client = new \GuzzleHttp\Client();
As mentioned earlier, you cannot use it βstaticallyβ
GuzzleClient::request('GET', 'https://api.xxxx');
Sem
source share