Using GuzzleHttp with Laravel

Chu Quang Tú
Apr 21, 2016 · 1 min read

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 composercurl -sS https://getcomposer.org/installer | 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

Laravel — In right way

About good practises and implementations in Laravel and…

Chu Quang Tú

Written by

A “mind-reading” fullstack web developer, a everyday-learner, a sharing-man , an amateur comic artist. And a husband & father.

Laravel — In right way

About good practises and implementations in Laravel and modern PHP

Chu Quang Tú

Written by

A “mind-reading” fullstack web developer, a everyday-learner, a sharing-man , an amateur comic artist. And a husband & father.

Laravel — In right way

About good practises and implementations in Laravel and modern PHP

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store