PHP Curl Class: Send HTTP requests and return responses using Curl

Recommend this page to a friend!
  Info   View files Documentation   View files View files (7)   DownloadInstall with Composer Download .zip   Reputation   Support forum (1)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-01-04 (8 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 171 This week: 1All time: 8,609 This week: 268Up
Version License PHP version Categories
curler 1.0Custom (specified...7.1HTTP, PHP 5
Description Author

This package can send HTTP requests and return responses using CURL.

It can send HTTP requests of different methods to a HTTP server with a given URL.

The class supports method like GET, POST, PUT, DELETE, DOWNLOAD, OPTIONS, HEAD and TRACE.

The request responses can be cached in local files in a give directory.

It also supports setting custom headers and values for specific Curl extension options.


Very Fast Curl class
The fastest Curl class

Picture of Josiah Ovye Yahaya
  Performance   Level  
Name: Josiah Ovye Yahaya is available for providing paid consulting. Contact Josiah Ovye Yahaya .
Classes: 6 packages by
Country: Nigeria Nigeria
Age: 30
All time rank: 256112 in Nigeria Nigeria
Week rank: 63 Up4 in Nigeria Nigeria Up
Innovation award
Innovation award
Nominee: 1x



An elegant PHP HTTP client for sending HTTP requests.


  • `php 7.1+`
  • `OpenSSL`
  • `cURL`


This library can easily be installed using composer. Run the command below:

composer require coderatio/curler



Because this is built with simplicity in mind from the beginning, below is how easy you can make a get request to another server.

require 'vendor/autoload.php';

$curler = new \Coderatio\Curler\Curler();
$response = $curler->getResponse();


$data = [
  'title' => 'Sample post',
  'body' => 'This is a sample post',
  'userId' => 1

$curler = new \Coderatio\Curler\Curler();
$request = $curler->post('', $data);
$response = $curler->getResponse();


Sending form data via curler is as simple sending a post request. Just send an array of your form data and curler will take care of the rest. Take a look below:

$data = [
  'first_name' => 'John',
  'last_name' => 'Doe',
  'email' => ''

$curler = new \Coderatio\Curler\Curler();
$request = $curler->postForm('', $data);
$response = $curler->getResponse();

By default, the $response variable will hold a json object of the request. But, there are instances where you want the response in php object or array. You can get them as below:

$response = $curler->getResponse()->asObject();


$response = $curler->getResponse()->asArray();


Other Request Methods

  1. PUT
  5. HEAD
  6. TRACE

Just as you use the post, get, postForm e.t.c, you can also use the put, delete, download, options, head, and trace methods.


Adding Custom Headers

Sometimes, you may need to send your request with custom headers. Curler, has full support for that and many more. Here is how it can be done. * ### Single Header

$curler = new \Coderatio\Curler\Curler();
$curler->appendRequestHeader('Content-Type', 'application/json');
$curler->post('', $data);

$response = $curler->getResponse();

  • ### Multiple headers

$curler = new \Coderatio\Curler\Curler(); $curler->appendRequestHeaders([

'Content-Type' => 'application/xml',
'x-access-token' => 'xxxxxxxxxx'


$curler->post('', $data);

$response = $curler->getResponse();


## Get Status Code
Sometimes, you may like to get the status code returned from a request. This can easily be done with curler as below:



## Add cURL options
Since this package is built with flexibility in mind, adding cURL options should be a breeze. Here is how you can add options:

$curler->addCurlOption('CURLOPT_PUT', true); // Single

// OR


'CURLOPT_PUT' => true,


## Contributors
To be a contributor, kindly fork the repo, add or fix bugs and send a pull request.

## Contribution
To contribute to this project, kindly fork it and send a pull request or find me on <a href="">Twitter</a>.

## License
This project is licenced with the MIT license.
  Files folder image Files  
File Role Description
Files folder imagesrc (1 file, 2 directories)
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file Doc. Documentation

  Files folder image Files  /  src  
File Role Description
Files folder imageExceptions (1 file)
Files folder imageServices (2 files)
  Plain text file Curler.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
  Plain text file CurlerException.php Class Class source

  Files folder image Files  /  src  /  Services  
File Role Description
  Plain text file CurlerCacheService.php Class Class source
  Plain text file CurlerHttpResponseService.php Class Class source

 Version Control Unique User Downloads Download Rankings  
This week:1
All time:8,609
This week:268Up

For more information send a message to info at phpclasses dot org.