PHPackages                             kite/curlback - 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. kite/curlback

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

kite/curlback
=============

Simple object wrapper for cURL

v2.2(11y ago)14375[2 issues](https://github.com/jwoodcock/CurlBack/issues)BSD-3-ClausePHPPHP &gt;=5.3.0

Since Jan 10Pushed 11y ago1 watchersCompare

[ Source](https://github.com/jwoodcock/CurlBack)[ Packagist](https://packagist.org/packages/kite/curlback)[ Docs](https://github.com/jwoodcock/CurlBack)[ RSS](/packages/kite-curlback/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (7)Used By (0)

cURLBack
========

[](#curlback)

Simple object wrapper for cURL

cURLBack is a simple cURL wrapper that allows storing of past requests for furture use without having to re-request a resource. cURLBack also provides a simple OOP interface for making and managing these requests.

INSTALL
-------

[](#install)

You can use Composer to install CurlBack.

    ```

        {
            "require": {
                "kite/curlback": "1.*"
            }
        }

```

QUICK START
-----------

[](#quick-start)

Using cURLBack is simple. Here's a simple example for making a request and printing the response.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com');
        $myRequest->makeRequest();
        print_r($myRequest->getResponse());

```

You can easily add GET variables one by one or via an array.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com');
        $myRequest->setGetValue("variable","value");
        $myRequest->makeRequest();
        print_r($myRequest->getResponse());

```

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com');
        $getValues = array(
            "variable" => "value",
            "variable2" => "value,
        );
        $myRequest->setGetValue($getValues);
        $myRequest->makeRequest();
        print_r($myRequest->getResponse());

```

The same goes for POST variables using the setPostValue() method.

You have multiple ways to interact with the response information from a request.

returnResponse() gives just the response from a request. returnRequestInfo() gives you the information from the response as well as the response headers. returnHttpCode() returns just the response HTTP Code

REQUEST METHOD
--------------

[](#request-method)

Like cURL, cURLBack is defaulted to use the GET method with requests but you may change the method using the changeToPost(), changeToDelete(), changeToPut() methods. There is also a changeToCustom() method for undocumented methods.

If you send POST variables, like cURL, cURLBack will automatically switch it's method to POST.

CONVENIENCE METHODS
-------------------

[](#convenience-methods)

cURLBack also has 4 convenience methods that allow you to build and make a request through one call. One for GET, POST, PUT and DELETE.

These look like the following:

    ```

        $curl = new Curl;
        $curl->post('http://www.example.com', array(
            'foo' => 'bar'
        ));

        $curl->get('http://www.example.com', array(
            'foo' => 'bar'
        ));

        $curl->put('http://www.example.com', array(
            'foo' => 'bar'
        ));

        $curl->delete('http://www.example.com');

```

SAVING REQUESTS
---------------

[](#saving-requests)

cURLBack has a built in request container that will store the information for each request you make.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->makeRequest();
        print_r($myRequest->returnSavedRequests());

```

The returnSavedRequests() method will return an object with all information about each requests along with the full response details. You can use the returnRequestList() and returnRequestListWithTimes() for abbreviated list with or without the request times.

ADDING AN ADDITIONAL REQUEST
----------------------------

[](#adding-an-additional-request)

To add additional request to the same cURLBack object, simply add a new request address and then make a new request.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->makeRequest();
        $myRequest->setAddress('http://www.yahoo.com');
        $myRequest->makeRequest();

```

Once you add a new request address, the previous request is moved to the pastResponses property. To access any of it's information you will want to call it as such.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->makeRequest();
        $myRequest->setAddress('http://www.yahoo.com');
        $myRequest->makeRequest();

        $myRequest->pastResponses[0]['response'];

```

REPLAY A REQUEST
----------------

[](#replay-a-request)

You can replay any previous saved request using the replayRequest() method.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->makeRequest();
        $myRequest->replayRequest(0);

```

CLEARING REQUEST HISTORY
------------------------

[](#clearing-request-history)

You can clear all request history using the resetStoredResponses() method.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->makeRequest();
        $myRequest->resetStoredResponses();

```

HEADERS &amp; GLOBAL ACCOUNT TYPE, USER
---------------------------------------

[](#headers--global-account-type-user)

You can also set HEADERs to the cURLBack object using the setHeader() method.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->setHeader("Content-type","application/json");
        $myRequest->makeRequest();

```

By default, cURLBack sets a global accept type header of 'application/json' but you can change this at will using the setGlobalAccept() method.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->setGlobalAccept('application/html');
        $myRequest->makeRequest();

```

Also, cURLBack is setup to store and send a USER header property for authentication propurses. Simply set the $this-&gt;globalUser using the setGlobalUser() method.

    ```

        $myRequest = new Kite\CurlBack\Curl('http://www.google.com',true);
        $myRequest->setGlobalUser('10ksd93023ksdfj0230kj23lk');
        $myRequest->makeRequest();

```

BATCH REQUESTS
==============

[](#batch-requests)

cURLBack also supports batch processing of requests using an instance of the main Curl object.

    ```

        $requests = array(
            array(
                "address"=>"http://www.kitewebconsulting.com",
                "method"=>"GET",
            )
        );

        $curl = new Curl("", true);
        $batchRequest = new BatchHandler($requests, $curl);
        $batchRequest->processRequests();

```

`The BatchHandler has an expanded interface as well for multiple methodsof interactions. Here is a list of all available methods.__construct($requests, $curl)The $requests is an array holder requests arrays. See following sectionfor structure and requirements.The $curl is an instance of the $curl object to make request and storeresponses.processBatchObj($requests)If you want to add the requests after the BatchHandler object has beeninstantiated you can use this method to pass in the request object.addRequest($request, $position)This method allows you to add requests one at a time. The $request objectis an array with a single request array within it and the $position isoptional but can be used to write over existing requests.clearRequests()Empties all the stored requests.processRequests($current)This is the main method for calling the requests and once called willloop through the request object until the last request is made.returnResponses()Instead of having to call your $curl object to get all the responsesa shortcut has been setup so you can call them using the $batchHandlerobject.$requests Object StructureHere is a list of the fields you can pass and which are required or optional.    address     (string - required)    method      (string - required)    getValues   (key value array - optional)    postValues  (key value array - optional)    headers     (key value array - optional)    accept      (string - optional)     user        (string - optional)    un          (string - required if pw is set)    pw          (string - required if un is set)    So a request with full options would look like this:            $requests = array(            array(                "address"=>"http://www.kitportal.com",                "method"=>"GET",                "getValues"=>array(                    "key"=>"val"                )                "postValues"=>array(                    "key"=>"val"                )                "headers"=>array(                    "key"=>"val"                )                "accept"=>"application/json",                "user"=>"myUser",                "un"=>"username",                "pw"=>"password",            )        );    PUBLIC PROPERTIES$address = The active address to use when doing a request.$getValues = An array holding all the get values of the active request.$postValues = An array holding all the post values of the active request.$method = The request method, POST, GET, PUT, DELTE or Custom$storeRequests = Boolean for turning on or off request saving. $pastResponses = Array holding all the past request and respones if storeRequests = true$globalAccept = The header ACCEPT type to use on all requests.$globalUser = The header USER to use on all requests if provided. FULL API LIST__construct($address, $storeRequests)The construct can take an valid URL as the $address and a boolean as the $storeRequests. Both are optional though. setAddress($address)This method sets the active request URL.echoAddress()This method simply prints the current active address. setGetValue($name, $value)The $name property can either be a string for the variable name or an array of variables and values. $value is only used if $name is a variable string and holdsthe value of that variable. setPostValue($name, $value = '', $json = false)The $name property can either be a string for the variable name or an array of variables and values. $value is only used if $name is a variable string and holdsthe value of that variable, unless you want to post a json object which case youwill set the object as the $value and set $json to true.Example:    $jsonObj = '{"hi":"friend"}';    $request->setPostValue('', $jsonObj, true);changeToPost()Changes $method to POSTchangeToPUT()Changes $method to PUT changeToDelete()Changes $method to DELETE changeToGet()Changes $method to GET customMethod($method)The $method will change the request method to your custom method.setHeader($name, $value)The $name will be the name of the header while $value is the value of that header.You can also just provide an array of headers in the name field to add bulk, just leave the value field empty. removeHeader($num)This method will remove a header from the header list via the provided $num.returnHeaderCount()This method returns the total count of the provided headers. setGlobalAccept($acceptType)This method changes the header ACCEPT type value. setGlobalUser($user)This method sets the header USER property.returnResponse()This method will return the response from the last request.returnHttpCode()This method returns the HTTP code from the last request.returnResponseInfo()This method returns an array holding the response info and response headers. Array (    "Response Info" : "info",    "Response Headers" : "info",) returnSavedRequests()Returns an array of all the past responses. setBasicAuth($un, $pw)    Sets basic authentication for the request with $un being the username and $pw being the password.LICENSECopyright (c) 2013, Kite, IncAll rights reserved.Redistribution and use in source and binary forms, with or without modification,are permitted provided that the following conditions are met:Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.Neither the name of the  nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" ANDANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AREDISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FORANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ONANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THISSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.`

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 70% 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

Every ~146 days

Total

5

Last Release

4311d ago

Major Versions

v1.1 → v2.12014-08-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/72dd444241273deae6f5aadeeeb6c25e4b92e9648ab8b5d6ddb8cd502671480c?d=identicon)[jwoodcock](/maintainers/jwoodcock)

---

Top Contributors

[![jwoodcock](https://avatars.githubusercontent.com/u/1666983?v=4)](https://github.com/jwoodcock "jwoodcock (56 commits)")[![ramsey](https://avatars.githubusercontent.com/u/42941?v=4)](https://github.com/ramsey "ramsey (19 commits)")[![mfrost503](https://avatars.githubusercontent.com/u/660067?v=4)](https://github.com/mfrost503 "mfrost503 (3 commits)")[![joecwallace](https://avatars.githubusercontent.com/u/925701?v=4)](https://github.com/joecwallace "joecwallace (2 commits)")

---

Tags

httpcurl

### Embed Badge

![Health badge](/badges/kite-curlback/health.svg)

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

###  Alternatives

[rmccue/requests

A HTTP library written in PHP, for human beings.

3.6k36.3M274](/packages/rmccue-requests)[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.5M274](/packages/nategood-httpful)[mashape/unirest-php

Unirest PHP

1.3k9.9M162](/packages/mashape-unirest-php)[php-http/curl-client

PSR-18 and HTTPlug Async client with cURL

49048.5M433](/packages/php-http-curl-client)[smi2/phpclickhouse

PHP ClickHouse Client

85111.1M78](/packages/smi2-phpclickhouse)[pear/http_request2

Provides an easy way to perform HTTP requests.

784.3M52](/packages/pear-http-request2)

PHPackages © 2026

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