PHPackages                             anlutro/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. anlutro/curl

ActiveLibrary

anlutro/curl
============

Simple OOP cURL wrapper.

1.5.4(6mo ago)2531.2M—2.5%49[2 PRs](https://github.com/anlutro/php-curl/pulls)20MITPHPPHP &gt;=5.3.0CI passing

Since Nov 1Pushed 5mo ago12 watchersCompare

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

READMEChangelog (10)Dependencies (2)Versions (43)Used By (20)

php-curl
========

[](#php-curl)

[![Latest Stable Version](https://camo.githubusercontent.com/3fab070a1f548f42d953f03e7ff36ce6731be2ad217937898d86a918ed54b36a/68747470733a2f2f706f7365722e707567782e6f72672f616e6c7574726f2f6375726c2f762f737461626c652e737667)](https://github.com/anlutro/php-curl/releases)[![Latest Unstable Version](https://camo.githubusercontent.com/15ddd9a6c21e35f4355fdfec1346a0c63e33471a34c70e358bc934c1300ac783/68747470733a2f2f706f7365722e707567782e6f72672f616e6c7574726f2f6375726c2f762f756e737461626c652e737667)](https://github.com/anlutro/php-curl/branches/active)[![License](https://camo.githubusercontent.com/f2ab7e27a0d935eba4accb8e39ede9fc9f522aa0a9f3f8c8023dc2e6d755fa1c/68747470733a2f2f706f7365722e707567782e6f72672f616e6c7574726f2f6375726c2f6c6963656e73652e737667)](http://opensource.org/licenses/MIT)

The smallest possible OOP wrapper for PHP's curl capabilities.

Note that this is **not** meant as a high-level abstraction. You should still know how "pure PHP" curl works, you need to know the curl options to set, and you need to know some HTTP basics.

If you're looking for a more user-friendly abstraction, check out [Guzzle](http://guzzle.readthedocs.org/en/latest/).

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

[](#installation)

```
$ composer require anlutro/curl

```

Usage
-----

[](#usage)

```
$curl = new anlutro\cURL\cURL;

$response = $curl->get('http://www.google.com');

// easily build an url with a query string
$url = $curl->buildUrl('http://www.google.com', ['s' => 'curl']);
$response = $curl->get($url);

// the post, put and patch methods takes an array of POST data
$response = $curl->post($url, ['api_key' => 'my_key', 'post' => 'data']);

// add "json" to the start of the method to convert the data to a JSON string
// and send the header "Content-Type: application/json"
$response = $curl->jsonPost($url, ['post' => 'data']);

// if you don't want any conversion to be done to the provided data, for example
// if you want to post an XML string, add "raw" to the start of the method
$response = $curl->rawPost($url, '
