Using GuzzleHttp with Laravel

Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.

Here is the steps list that you need to do to make it work with Laravel

  • Go to your root of Laravel project
  • Install Guzzle package via composer :
# If you don't have composer
curl -sS | php
php composer.phar require guzzlehttp/guzzle
# If you already have composer installed globally
composer require guzzlehttp/guzzle
  • Use its namespace
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Client;
  • Then use it easily, e.g :
$client = new Client(); //GuzzleHttp\Client
$result = $client->post('your-request-uri', [
'form_params' => [
'sample-form-data' => 'value'
  • That’s it. You could do more with Guzzle. Check its latest doc then master it