Guzzle HTTP GET & POST Request in Laravel 9

Guzzle HTTP GET & POST Request in Laravel 9

Laravel 9 guzzle get post request; In this tutorial, we will learn How to use Guzzle HTTP Client GET and POST requests in PHP Laravel 9.

POST requests in Guzzle are sent with an application/x-www-form-urlencoded Content-Type header if POST fields are present but no files are being sent in the POST. If files are specified in the POST request, then the Content-Type header will become multipart/form-data.

Sometimes, you need to call external or internal APIs in your laravel 9 apps. At that time you can use HTTP guzzle client request in laravel 9. which makes it easy to call external APIs in laravel 9 with get and post request.

Guzzle HTTP GET & POST Request in Laravel 9

Use the following steps to use guzzle HTTP client get and post request in laravel 9:

  • Step 1: Install Laravel 9 App
  • Step 2: Database Configuration
  • Step 3: Install guzzlehttp/guzzle Package
  • Step 4: Make Routes
  • Step 5: Create Controllers By Artisan
  • Step 6: Run Development Server

Step 1: Install Laravel 9 App

First of all, Open your terminal and run the following command to download or install laravel fresh new setup:

composer create-project --prefer-dist laravel/laravel blog

Step 2: Database Configuration

After that, open “.env” file and update the database name, username, and password in the env file:


Step 3: Install guzzlehttp/guzzle Package

In this step, Install guzzlehttp/guzzle via composer package. So open your terminal and run the following command:

composer require guzzlehttp/guzzle

Step 4: Make Routes

Next step, Navigate to “routes/web.php” file and add the following routes into your web.php file:

use App\Http\Controllers\PostGuzzleController;

Route::get('posts/store', [PostGuzzleController::class, 'store' ]);

Step 5: Create Controllers by Artisan

Next step, open your terminal and run the following commands:

php artisan make:controller PostGuzzleController

This command will create PostGuzzleController by the artisan command.

After that, Navigate to app/http/controller and open PostGuzzleController.php.Then update the following methods into your controller file:


namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Http;

class PostGuzzleController extends Controller
    public function index()
        $response = Http::get('');
        $jsonData = $response->json();

    public function store()
        $response = Http::post('', [
                    'title' => 'This is test from',
                    'body' => 'This is test from as body',

Step 6: Run Development Server

In this step, use the following php artisan serve command to start your server locally:

php artisan serve

After that, call the above method with parameters on postman by using the following urls:


Laravel 9 HTTP guzzle client request tutorial, you have learned how to use guzzle HTTP client requests in laravel 9 apps by using laravel guzzle package.

Recommended Laravel Tutorials


My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

One reply to Guzzle HTTP GET & POST Request in Laravel 9

  1. Thank you so much.

Leave a Reply

Your email address will not be published. Required fields are marked *