Laravel’s ixudra package offers an effective method for making HTTP requests using curl.

Use curl to send get and post requests by performing the following actions:

  1. Install the package ixudra/curl.
  2. Adjust the installed package’s settings.
  3. In your controller code, import the class.
  4. Use curl to send get and post requests.

Install the ixudra/curl package

Installing ixudra/curl for your application using a composer command is possible and is demonstrated below:

composer require ixudra/curl

Configure the installed package

Your app.php file should now include the providers and aliases. The config directory must contain the app.php file.

'providers' => [




'aliases' => [


    'Curl' => Ixudra\Curl\Facades\Curl::class,


Import the class in your controller

You must include the class in your controller file as shown below in order to add it to your controller:

use Ixudra\Curl\Facades\Curl;


Create a method called getCurl() in the controller where you wish to implement the curl .

Note: You can give the method whatever name you choose, but getCurl() is used in this example.

Get request

Let’s use this package to make a get() request.

public function getCURL()
$response = Curl::to('')

The get request is sent in the code above using the Curl:: facade and the to() method, and the response is then dumped.

In your situation, you might wish to execute the logic necessary for your application rather than dumping the result.

Post request

public function getCURL()


    $response = Curl::to('')

                ->withData(['title'=>'Test', 'body'=>'sdsd', 'userId'=>1])




The post request is made in the code above using the to() method, and the withData parameter specifies what data must be provided. The response is dropped once more.

The put request in the code above can be replaced with the patch, put, or delete requests.

Recommended Posts

View All

Laravel 9 Create Multi Language Website Example Tutorial

Learn how to create a multi-language website with Laravel 9 through our example tutorial. Develop your skills and broaden your audience reach today!

Laravel Where Clause with MySQL Function Example

laravel eloquent where year,laravel eloquent mysql functions,laravel eloquent where clause mysql,mysql function mysql laravel

How to Use Yajra Datatables in Laravel 9 Application

Learn how to enhance your Laravel 9 application with Yajra Datatables. This tutorial will guide you through the steps of integrating and using it.

Laravel 9 Capture Image from Webcam and Store in Database

Learn how to capture images from webcam using Laravel 9 and store them in a database. Step-by-step guide with code examples and best practices.

Most Important Array Methods in JavaScript

Learn the most important array methods in JavaScript, including push, pop, shift, unshift, forEach, map, filter, reduce, and find. Improve your coding...