PHPackages                             net\_bazzline/php\_component\_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. net\_bazzline/php\_component\_curl

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

net\_bazzline/php\_component\_curl
==================================

free as in freedom simple object oriented curl request and response component (YACC - yet another curl component)

1.0.0(9y ago)91.3k2[1 issues](https://github.com/bazzline/php_component_curl/issues)1LGPL-3.0PHPPHP &gt;=5.3.3

Since Dec 10Pushed 7y ago7 watchersCompare

[ Source](https://github.com/bazzline/php_component_curl)[ Packagist](https://packagist.org/packages/net_bazzline/php_component_curl)[ RSS](/packages/net-bazzline-php-component-curl/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (3)Versions (27)Used By (1)

Simple Curl Wrapper Component for PHP
=====================================

[](#simple-curl-wrapper-component-for-php)

This project aims to deliver an easy to use and free as in freedom object oriented php curl command component.

The build status of the current master branch is tracked by Travis CI: [![Build Status](https://camo.githubusercontent.com/228399143508fdcdf2f76dab2c1e25e858467f2252100012d962825f238f743a/68747470733a2f2f7472617669732d63692e6f72672f62617a7a6c696e652f7068705f636f6d706f6e656e745f6375726c2e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/bazzline/php_component_curl)[![Latest stable](https://camo.githubusercontent.com/0f38f6467962373fe753cd5dc540596a2f14a73dab3bcccf5aa11890d6146c97/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e65745f62617a7a6c696e652f7068705f636f6d706f6e656e745f6375726c2e737667)](https://packagist.org/packages/net_bazzline/php_component_curl)

The scrutinizer status is: [![code quality](https://camo.githubusercontent.com/4504dad67b1d66b7f9b31f6876640a018536d726dcf6c4ab44f6eb3d73556f4f/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f62617a7a6c696e652f7068705f636f6d706f6e656e745f6375726c2f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bazzline/php_component_curl/)

The versioneye status is: [![Dependency Status](https://camo.githubusercontent.com/6128c6e38bd3892cd459cd0624f4e4a19e42f4416a9f43675f794f29ecdfeff0/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f757365722f70726f6a656374732f3535333934313536306232343232356566363030303030322f62616467652e7376673f7374796c653d666c6174)](https://www.versioneye.com/user/projects/553941560b24225ef6000002)

Take a look on [openhub.net](https://www.openhub.net/p/php_component_curl).

The current change log can be found [here](https://github.com/bazzline/php_component_curl/blob/master/CHANGELOG.md).

This component is not developed to replace [guzzle](http://docs.guzzlephp.org/en/latest/).

Example
=======

[](#example)

By Using The Builder
--------------------

[](#by-using-the-builder)

```
//it is always good to ship the component with a factory to easy up usage
use Net\Bazzline\Component\Curl\BuilderFactory;
use Net\Bazzline\Component\Curl\Option\Timeout;

$factory    = new BuilderFactory();
$builder    = $factory->create();
$url        = 'http://www.foo.bar';
$timeout    = new Timeout(10);  //set the timeout to 10 seconds

/**
 * you can also use:
 *  //assuming that $dispatcher is an instance of DispatcherInterface
 *  //assuming that $requestFactory is an instance of RequestFactory
 *  $builder->overwriteDispatcher($dispatcher);
 *  $builder->overwriteRequestFactory($requestFactory);
 */

$response = $builder->usePost()
    ->onTheUrl($url)
    ->withTheData($data)
    ->withTheParameters(array('descendingOrderBy' => 'id'))
    ->withTheOption($timeout)
    ->andFetchTheResponse();

/**
 * you can also use:
 *  $builder->withTheHeaderLine($headLine)    //add the headline you want
 *  $builder->withResponseModifier($modifier) //add the response modifier you want
 */

echo 'content: ' . $response->content() . PHP_EOL;
echo 'content type: ' . $response->contentType() . PHP_EOL;
echo 'error:' . $response->error() . PHP_EOL;
echo 'error code:' . $response->errorCode() . PHP_EOL;
echo 'head lines: ' . var_export($response->headerLines(), true) . PHP_EOL;
echo 'status code: ' . $response->statusCode() . PHP_EOL;
```

By Using The Request
--------------------

[](#by-using-the-request)

```
//it is always good to ship the component with a factory to easy up usage
$factory    = new Net\Bazzline\Component\Curl\RequestFactory();
$request    = $factory->create();
$url        = 'http://www.foo.bar';

$response = $request->get($url);

echo 'content: ' . $response->content() . PHP_EOL;
echo 'content type: ' . $response->contentType() . PHP_EOL;
echo 'error:' . $response->error() . PHP_EOL;
echo 'error code:' . $response->errorCode() . PHP_EOL;
echo 'head lines: ' . var_export($response->headerLines(), true) . PHP_EOL;
echo 'status code: ' . $response->statusCode() . PHP_EOL;
```

Executable Examples
-------------------

[](#executable-examples)

- [Delete Request](https://github.com/bazzline/php_component_curl/blob/master/example/make_a_delete_request)
- [Get Request](https://github.com/bazzline/php_component_curl/blob/master/example/make_a_delete_request)
- [Patch Request](https://github.com/bazzline/php_component_curl/blob/master/example/make_a_patch_request)
- [Post Request](https://github.com/bazzline/php_component_curl/blob/master/example/make_a_post_request)
- [Put Request](https://github.com/bazzline/php_component_curl/blob/master/example/make_a_put_request)

More Examples
-------------

[](#more-examples)

### Post Request With Basic Authentication

[](#post-request-with-basic-authentication)

```
//begin of runtime environments
$factory        = new BuilderFactory();
$builder        = $factory->create();
$data           = array(
    'there'     => 'is',
    'no'        => 'foo',
    'without'   => 'a bar'
);
$password       = '';
$username       = 'foo@bar.ru';
$url            = 'https://foo.bar.ru/api/my/rest/endpoint/v1';
//end of runtime environments

//begin building the request
$builder->asJson();
$builder->onTheUrl($url);
$builder->withTheData($data);
$builder->withTheOption(new SetBasicAuthentication());
$builder->withTheOption(new SetUsernameAndPassword($username, $password));
$builder->usePost();
//end building the request

$request = $builder->andFetchTheResponse();
echo PHP_EOL . 'dumping the request' . PHP_EOL;
var_dump($request);

```

Terms
=====

[](#terms)

- [Dispatcher](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/Dispatcher/Dispatcher.php)
    - doing the curl request
    - if you want to use pure curl, use this class
- [Request](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/Request/Request.php)
    - object oriented approach reflecting the request
    - [HeadLine](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/HeadLine/HeadLineInterface.php)
        - object oriented [http headers](https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html) ([list](https://en.wikipedia.org/wiki/List_of_HTTP_header_fields) of available headers), start a pull request if you need more
    - [Options](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/Option/OptionInterface.php)
        - object oriented curl options, start a pull request if you need more
    - Parameters
        - all the parameters you want to add to your url - they are urlencoded automatically
    - Url
        - the url of your endpoint
- [Response](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/Response/Response.php)
    - object oriented approach reflecting the response
    - [ResponseBehaviour](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/ResponseBehaviour/ResponseBehaviourInterface.php)
        - interface to interact with the response
            - either modify the response (by creating a new one)
            - change the flow by throwing an exception if the response does not fits your needs (as example)
- [Builder](https://github.com/bazzline/php_component_curl/blob/master/source/Net/Bazzline/Component/Curl/Builder/Builder.php)
    - provides a fluent interface to easy up using curl
    - it takes care of all :-)

Not Available Curl Options
==========================

[](#not-available-curl-options)

In general, the php version is limiting the available [curl options](http://php.net/manual/en/curl.constants.php). Furthermore, some options are not implemented because of their hardcoded usage in the *Response* or the *Dispatcher* (you can set it but they would be overwritten).

This options are:

- used in the *Request*
    - CURLOPT\_CUSTOMREQUEST
    - CURLOPT\_HTTPHEADER
    - CURLOPT\_POSTFIELDS
- used in the *Dispatcher*
    - CURLINFO\_HEADER\_OUT
    - CURLOPT\_HEADERFUNCTION
    - CURLOPT\_RETURNTRANSFER

If you want to change this, you either have to extend the existing *Request* or *Dispatcher* object.

Install
=======

[](#install)

By Hand
-------

[](#by-hand)

```
mkdir -p vendor/net_bazzline/php_component_curl
cd vendor/net_bazzline/php_component_curl
git clone https://github.com/bazzline/php_component_curl .

```

With [Packagist](https://packagist.org/packages/net_bazzline/php_component_curl)
--------------------------------------------------------------------------------

[](#with-packagist)

```
composer require net_bazzline/php_component_curl:dev-master

```

Links
=====

[](#links)

-

Other Components Available
--------------------------

[](#other-components-available)

-
-
-
-
-
-
-
-

Final Words
===========

[](#final-words)

Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. [Donate something](https://gratipay.com/~stevleibelt) if you love it :-\].

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor1

Top contributor holds 99.1% 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 ~20 days

Recently: every ~54 days

Total

26

Last Release

3357d ago

Major Versions

0.15.1 → 1.0.02017-04-22

### Community

Maintainers

![](https://www.gravatar.com/avatar/58451b041f6f5a38c7e62762c96d01f5e2bcac30e322707fe4760a82bccb6856?d=identicon)[artodeto](/maintainers/artodeto)

---

Top Contributors

[![stevleibelt](https://avatars.githubusercontent.com/u/2287220?v=4)](https://github.com/stevleibelt "stevleibelt (105 commits)")[![tworzenieweb](https://avatars.githubusercontent.com/u/741378?v=4)](https://github.com/tworzenieweb "tworzenieweb (1 commits)")

---

Tags

bazzlinebuilderchangelogcurlcurl-optionsdispatcherfree-as-in-freedomlgplv3oopphp56php7php71psrpsr-4requestresponseyet-anotherresponserequestpsrcurlbazzlinelgplfree as in freedomPSR-4dispatcherPHP7OOPyaccyet another

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/net-bazzline-php-component-curl/health.svg)

```
[![Health](https://phpackages.com/badges/net-bazzline-php-component-curl/health.svg)](https://phpackages.com/packages/net-bazzline-php-component-curl)
```

###  Alternatives

[psr/http-message

Common interface for HTTP messages

7.0k1.1B6.7k](/packages/psr-http-message)[psr/http-factory

PSR-17: Common interfaces for PSR-7 HTTP message factories

1.9k747.1M2.6k](/packages/psr-http-factory)[fig/http-message-util

Utility classes and constants for use with PSR-7 (psr/http-message)

39397.5M306](/packages/fig-http-message-util)[psr/http-server-handler

Common interface for HTTP server-side request handler

180114.7M1.2k](/packages/psr-http-server-handler)[psr/http-server-middleware

Common interface for HTTP server-side middleware

185103.9M1.8k](/packages/psr-http-server-middleware)[aplus/http-client

Aplus Framework HTTP Client Library

2171.6M1](/packages/aplus-http-client)

PHPackages © 2026

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