PHPackages                             rakit/curl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [HTTP &amp; Networking](/categories/http)
4. /
5. rakit/curl

ActiveLibrary[HTTP &amp; Networking](/categories/http)

rakit/curl
==========

Another php curl library

v0.1.0(10y ago)6413MITPHP

Since Jan 24Pushed 10y ago3 watchersCompare

[ Source](https://github.com/rakit/curl)[ Packagist](https://packagist.org/packages/rakit/curl)[ RSS](/packages/rakit-curl/feed)WikiDiscussions master Synced 2mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

rakit-curl
==========

[](#rakit-curl)

Just another PHP cURL wrapper

Installation
------------

[](#installation)

As you can see, this library contain `composer.json` file. But at this time, i have not post this library on packagist. So if you want to use it via composer, you can manually add this repository in your `composer.json` file.

So, your `composer.json` file should look like this:

```
{
    "require": {
        "rakit/curl": "dev-master"
    },
    "repositories": [
        {
            "url": "https://github.com/emsifa/rakit-curl",
            "type": "vcs"
        }
    ]
}
```

Then you can run `composer install` or `composer update`.

Optionally you can download/clone this library and load it into your project.

Examples
--------

[](#examples)

#### Example Get Request

[](#example-get-request)

```
use Rakit\Curl\Curl;

$request = new Curl('http://wikipedia.com');
$response = $request->get();

// then, you can do something with response object
if(! $response->error()) {

  // getting response file content
  $html = $response->getBody();

  // simply get response content type
  $content_type = $response->getContentType();

  // get content type via curl info
  $content_type = $response->getInfo('content_type');

  // getting response cookies
  $cookie = $response->getCookie();

  // simply get response header item
  $http_version = $response->getHeader('http_version');

  // get all header items
  $all_headers = $response->getHeaders();

} else {

  $error_code = $response->getErrno();
  $error_message = $response->getErrorMessage();

}
```

#### Using Request Parameter

[](#using-request-parameter)

```
use Rakit\Curl\Curl;

$request = new Curl('http://targetsite.com/products');
$request->param('page', 2);
$request->param('category', 'software');
$response = $request->get();

// do something with Response object
```

**or**

```
use Rakit\Curl\Curl;

$params = array(
  'page' => 2,
  'category' => 'software'
);

$request = new Curl('http://targetsite.com/products');
$response = $request->get($params);

// do something with Response object
```

#### Example Post Request

[](#example-post-request)

```
use Rakit\Curl\Curl;

$request = new Curl('http://targetsite.com/register');
$request->param('name', 'John Doe');
$request->param('email', 'johndoe@mail.com');
$request->param('password', '12345');
$response = $request->post();

// do something with Response object
```

#### Upload file? use addFile method

[](#upload-file-use-addfile-method)

```
use Rakit\Curl\Curl;

$request = new Curl('http://targetsite.com/register');
$request->param('name', 'John Doe');
$request->param('email', 'johndoe@mail.com');
$request->param('password', '12345');

$request->addFile('avatar', 'path/to/avatar.png');

$response = $request->post();

// do something with Response object
```

#### Send a cookie

[](#send-a-cookie)

```
use Rakit\Curl\Curl;

$request = new Curl('http://targetsite.com/products');
$request->cookie('key', 'value');
$response = $request->get();

// do something with Response object
```

#### Auto Redirect

[](#auto-redirect)

Auto redirect allow cURL to auto redirect while response is redirection (status: 3xx).

Example:

```
use Rakit\Curl\Curl;

$request = new Curl('http://targetsite.com/admin/product/delete/1');
$request->autoRedirect(5); // 5 is maximum redirection

$response = $request->get();

// what if 6th request is also redirection? it's good to check
if($response->isRedirect()) {
    throw new \Exception("Too many redirection");
}

// do something with response
```

#### Storing Session

[](#storing-session)

It is easy way to store session automatically with CURLOPT\_COOKIEJAR and CURLOPT\_COOKIEFILE. It is useful when you want to grab something that require session cookies to login or anything else. For use this, you must have directory that have access to write file for storing session.

For example you want grab redirected page after login:

```
use Rakit\Curl\Curl;

$session_file = "path/to/store/sitetarget.session";

$request = new Curl("http://sitetarget.com/login");
$request->autoRedirect(5);
$request->storeSession($session_file);

$response = $request->post(array(
    'username' => 'my_username',
    'password' => 'my_password'
));

// do something with response object
```

#### Create Simple Request

[](#create-simple-request)

With simple request, you dont't need to create new Curl request object. But you can't send a cookie, modify request headers, or even curl options.

```
use Rakit\Curl\Curl;

// simple GET
$response = Curl::doGet('http://targetsite.com', array('page' => 2));

// simple POST
$response = Curl::doPost('http://targetsite.com/product/delete', array('id' => 5));
```

Response Object
---------------

[](#response-object)

In examples above, i always told you to do something with response object, but what it is? what you can do with response object?

Response object is object that returned from your cURL request. Response object contain result data from HTTP response such as response headers, cookies, body, etc.

Here is that you can do with response object:

#### isNotFound()

[](#isnotfound)

Shortcut for check response status code is 404 or not.

```
$response = Curl::doGet("http://sitetarget.com/blablabla");

if($response->isNotFound()) {
   // 404 page not found
}
```

#### isRedirect()

[](#isredirect)

Return true if status code is 3xx.

```
// redirecting example

$response = Curl::doGet("http://sitetarget.com/redirect-me");

while($response->isRedirect()) {
    $redirect_url = $response->getHeader("location");
    $response = Curl::doGet($redirect_url);
}
```

#### getBody()

[](#getbody)

Getting response body like html code, image content, etc.

#### length()

[](#length)

Getting response length (response body string + response header string).

#### isHtml()

[](#ishtml)

Return true if response content-type is text/html.

#### error()

[](#error)

Return true if there is error in request

#### getErrno()

[](#geterrno)

Getting error code, 0 = no error.

#### getErrorMessage()

[](#geterrormessage)

Getting error message, empty if no error

#### getHeader($key, $default = null)

[](#getheaderkey-default--null)

Getting header item

```
$response = Curl::doGet("http://sitetarget.com");

$http_version = $response->getHeader("http_version");
$content_type = $response->getHeader("content-type");
// and many more
```

#### getHeaders()

[](#getheaders)

Getting all header items as array.

#### getHeaderString()

[](#getheaderstring)

Get response headers as raw header string.

#### getStatusCode()

[](#getstatuscode)

Getting response status code.

#### getContentType()

[](#getcontenttype)

Shortcut for getting response content-type.

#### getInfo($key, $default = null)

[](#getinfokey-default--null)

Getting info item like curl\_getinfo()

#### getAllInfo()

[](#getallinfo)

Getting all info as array.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

3764d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/bf2e85e5574fc28f87c28311a5ad7bcbec884e9ea21e88d63639f46ed6af72d1?d=identicon)[emsifa](/maintainers/emsifa)

---

Top Contributors

[![emsifa](https://avatars.githubusercontent.com/u/6297931?v=4)](https://github.com/emsifa "emsifa (21 commits)")

### Embed Badge

![Health badge](/badges/rakit-curl/health.svg)

```
[![Health](https://phpackages.com/badges/rakit-curl/health.svg)](https://phpackages.com/packages/rakit-curl)
```

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M319](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M293](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

Event-driven, streaming HTTP client and server implementation for ReactPHP

78126.4M414](/packages/react-http)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
