PHPackages                             neutrino/http - 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. neutrino/http

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

neutrino/http
=============

The Neutrino Http package.

1.0.x-dev(9y ago)110MITPHPPHP &gt;=5.6

Since Apr 28Pushed 9y ago1 watchersCompare

[ Source](https://github.com/pn-neutrino/http)[ Packagist](https://packagist.org/packages/neutrino/http)[ Docs](https://phalcon-nucleon.github.io)[ RSS](/packages/neutrino-http/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (2)Dependencies (3)Versions (5)Used By (0)

Neutrino : Http Client component
================================

[](#neutrino--http-client-component)

[![Build Status](https://camo.githubusercontent.com/90e562facbeafd1cd701c25b72feefde3d122b1a964f59422cf4343eba75af4a/68747470733a2f2f7472617669732d63692e6f72672f706e2d6e65757472696e6f2f687474702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pn-neutrino/http) [![Coverage Status](https://camo.githubusercontent.com/c8f287e21b444b99a9d728c89aa1cb129eac9078cbcc9f51946d5be1d1acd7b3/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f706e2d6e65757472696e6f2f687474702f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/pn-neutrino/http)

Http Client library using Curl or HttpStream.

Basic
=====

[](#basic)

```
$provider->get($url, $parameters, $options);
$provider->post($url, $parameters, $options);
$provider->delete($url, $parameters, $options);
$provider->put($url, $parameters, $options);
$provider->head($url, $parameters, $options);
$provider->patch($url, $parameters, $options);

$provider->request($method, $url, $parameters, $options);
```

`$url` Contain the url to call. `$parameters` Contain the parameters to send. `$options` Contain the options of the request.

```
$options = [
    // Headers to send
    'headers' => [],
    // Retrieve the full response (Header + Body)
    'full' => true,
    // Make a JsonRequest (Only for POST, PUT, PATCH methods)
    'json' => true,
];
```

Provider
========

[](#provider)

Curl
----

[](#curl)

require curl extension.

#### How use :

[](#how-use-)

```
use \Neutrino\Http\Provider\Curl as HttpCurl;
use \Neutrino\Http\Method;

$curl = new HttpCurl;

$response = $curl
    ->get('http://www.google.com', ['foo' => 'bar'], ['Accept' => 'text/plain'])
    ->send();

$response->code; // HTTP Status Code
```

### Curl\\Streaming

[](#curlstreaming)

Curl\\Stream allows you to work with large queries, by recovers content part by part.

#### How use :

[](#how-use--1)

```
use \Neutrino\Http\Provider\Curl\Streaming as HttpCurlStream;
use \Neutrino\Http\Method;

$curl = new HttpCurlStream;

$response = $curl
    ->get('http://www.google.com')
    ->on(HttpCurlStream::EVENT_START, function (HttpCurlStream $curl) {
        // Start to download response body
        // Header are fully loaded when the event are raised
    })
    ->on(HttpCurlStream::EVENT_PROGRESS, function (HttpCurlStream $curl, $content) {
        // Download progress
        // $content contain the response part
    })
    ->send();
```

Transfer huge data, without overloading the php memory :

```
$curl
    ->get('http://www.google.com')
    ->on(HttpCurlStream::EVENT_START, function (HttpCurlStream $curl) {
        if ($curl->getResponse()->header->has('Content-Length')) {
            header('Content-Length: ' . $curl->getResponse()->header->get('Content-Length'));
        }
    })
    ->on(HttpCurlStream::EVENT_PROGRESS, function (HttpCurlStream $curl, $content) {
        echo $content;
        ob_flush();
        flush();
        // => Direct echo contents & flush the output (free memory)
    })
    ->send();
```

Download huge file, without overloading the php memory :

```
$resource = fopen($path, 'w');

$curl
    ->get('http://www.google.com')
    ->on(HttpCurlStream::EVENT_PROGRESS, function (HttpCurlStream $curl, $content) use ($resource) {
        fwrite($resource, $content, strlen($content));
    })
    ->send();

fclose($resource);
```

StreamContext
-------------

[](#streamcontext)

StreamContext make HTTP call via the php wrapper.

This require you have "allow\_url\_fopen" configuration value set to '1'.

#### How use :

[](#how-use--2)

```
use \Neutrino\Http\Provider\StreamContext as HttpStreamCtx;
use \Neutrino\Http\Method;

$streamCtx = new HttpStreamCtx;

$response = $streamCtx
    ->get('http://www.google.com', ['foo' => 'bar'], ['headers' => ['Accept' => 'text/plain']])
    ->send();

$response->code; // HTTP Status Code
```

### StreamContext\\Streaming

[](#streamcontextstreaming)

Such as Curl\\Streaming, StreamContext\\Streaming allows you to work with large queries, by recovers content part by part.

#### How use :

[](#how-use--3)

```
use \Neutrino\Http\Provider\StreamContext\Streaming as HttpStreamCtxStreaming;
use \Neutrino\Http\Method;

$streamCtx = new HttpStreamCtxStreaming;

$response = $streamCtx
    ->get('http://www.google.com')
    ->on(HttpStreamCtxStreaming::EVENT_START, function (HttpStreamCtxStreaming $streamCtx) {
        // Start to download response body
        // Header are fully loaded when the event are raised
    })
    ->on(HttpStreamCtxStreaming::EVENT_PROGRESS, function (HttpStreamCtxStreaming $streamCtx, $content) {
        // Download progress
        // $content contain the response part
    })
    ->send();
```

Auth
====

[](#auth)

Authentication is a request component.

Auth\\Basic
-----------

[](#authbasic)

Auth\\Basic provides the elements to configure a call with an Basic Authorization.

#### How use :

[](#how-use--4)

```
use \Neutrino\Http\Auth\Basic as AuthBasic;
use \Neutrino\Http\Provider\StreamContext as HttpStreamCtx;
use \Neutrino\Http\Method;

$streamCtx = new HttpStreamCtx;

$response = $streamCtx
    ->get('http://www.google.com')
    ->setAuth(new AuthBasic('user', 'pass'))
    ->send();
```

Auth\\Curl
----------

[](#authcurl)

Specific for Curl provider.

Auth\\Curl provides the elements to build a call with Curl Auth.

#### How use :

[](#how-use--5)

```
use \Neutrino\Http\Auth\Curl as AuthCurl;
use \Neutrino\Http\Provider\Curl as HttpCurl;
use \Neutrino\Http\Method;

$curl = new HttpCurl;

$response = $curl
    ->get('http://www.google.com')
    ->setAuth(new AuthCurl(CURLAUTH_BASIC | CURLAUTH_DIGEST, 'user', 'pass'))
    ->send();
```

Custom Auth Component
---------------------

[](#custom-auth-component)

You can easily make your own Auth Component :

```
namespace MyLib\Http\Auth;

use Neutrino\Http\Request;
use Neutrino\Http\Contract\Request\Component;

class Hmac implements Component
{
    private $id;
    private $value;

    public function __construct($id, $value)
    {
        $this->id = $id;
        $this->value = $value;
    }

    public function build(Request $request)
    {
        $date = date('D, d M Y H:i:s', time());
        $signature = urlencode(base64_encode(hash_hmac('sha1', "date: $date", $this->value, true)));

        $request
            ->setHeader('Date', $date)
            ->setHeader('Authorization', 'Signature keyId="' . $this->id . '",algorithm="hmac-sha1",signature="' . $signature . '"');
    }
}
```

```
use \MyLib\Http\Auth\Hmac as AuthHmac;
use \Neutrino\Http\Provider\Curl as HttpCurl;
use \Neutrino\Http\Method;

$curl = new HttpCurl;

$response = $curl
    ->get('http://www.google.com')
    ->setAuth(new AuthHmac('key_id', 'key_value'))
    ->send();
```

Response
========

[](#response)

Basic
-----

[](#basic-1)

```
$response->code;   // HTTP Status Code
$response->status; // HTTP Status Message
$response->header; // Response Headers
$response->body;   // Response Body
```

Provider Info
-------------

[](#provider-info)

```
$response->errorCode; // Provider Error Code
$response->error;     // Provider Error Message
$response->providerDatas; // All Provider Information (if available)
```

Parse
-----

[](#parse)

```
use \Neutrino\Http\Parser;

// Json Body => Object
$jsonObject = $response->parse(Parser\Json::class)->data;

// Xml Body => SimpleXMLElement
$xmlElement = $response->parse(Parser\Xml::class)->data;

// Xml Body => array
$xmlArray = $response->parse(Parser\XmlArray::class)->data;

// Other exemple : (PHP7)
$response->parse(new class implements Parser\Parserize
{
    public function parse($body)
    {
        return unserialize($body);
    }
});

$response->data; // Unserialized body
```

###  Health Score

22

—

LowBetter than 21% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity47

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

Every ~1 days

Total

4

Last Release

3345d ago

Major Versions

0.1.0-RC2 → 1.0.x-dev2017-05-03

### Community

Maintainers

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

---

Top Contributors

[![Ark4ne](https://avatars.githubusercontent.com/u/6144058?v=4)](https://github.com/Ark4ne "Ark4ne (25 commits)")

---

Tags

httpstreamjsonapirestxmlcurlhttp clientweb servicestreamingrestfulrequestsstream contextnucleonneutrino

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/neutrino-http/health.svg)

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

###  Alternatives

[php-curl-class/php-curl-class

PHP Curl Class makes it easy to send HTTP requests and integrate with web APIs.

3.3k9.8M372](/packages/php-curl-class-php-curl-class)[nategood/httpful

A Readable, Chainable, REST friendly, PHP HTTP Client

1.8k17.5M274](/packages/nategood-httpful)[ismaeltoe/osms

PHP library wrapper of the Orange SMS API.

4540.5k](/packages/ismaeltoe-osms)[e-moe/guzzle6-bundle

Integrates Guzzle 6 into your Symfony application

12261.2k1](/packages/e-moe-guzzle6-bundle)

PHPackages © 2026

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