PHPackages                             legionth/http-client-react - 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. legionth/http-client-react

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

legionth/http-client-react
==========================

v1.1.0(7y ago)1251MITPHPPHP &gt;=5.3CI failing

Since Aug 18Pushed 7y ago1 watchersCompare

[ Source](https://github.com/legionth/php-http-client-react)[ Packagist](https://packagist.org/packages/legionth/http-client-react)[ RSS](/packages/legionth-http-client-react/feed)WikiDiscussions master Synced 2w ago

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

legionth/http-client-react
==========================

[](#legionthhttp-client-react)

HTTP client written in PHP on top of ReactPHP.

**Table of Contents**

- [Usage](#usage)
    - [Request body](#request-body)
- [Install](#install)
- [License](#license)

Usage
-----

[](#usage)

The client is responsible to send HTTP requests and receive the HTTP response from the server.

This library uses [PSR-7](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md)objects to make it easier to handle the HTTP-Messsages.

```
$uri = 'tcp://httpbin.org:80';
$request = new Request('GET', 'http://httpbin.org');

$promise = $client->request($uri, $request);
```

It could take some time until the response is transferred from the server to the client. For this reason the `request`-method will return a [ReactPHP promise](https://github.com/reactphp/promise).

The promise will result in a [PSR-7 response object](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-7-http-message.md#33-psrhttpmessageresponseinterface)

```
$promise = $client->request($uri, $request);
$promise->then(
    function (\Psr\Http\Message\ResponseInterface $response) {
        echo 'Successfully received a response from the server:' . PHP_EOL;
        echo RingCentral\Psr7\str($response);
    },
    function (\Exception $exception) {
        echo $exception->getMessage() . PHP_EOL;
    }
);
```

The body of the response will always be an asynchronous [ReactPHP Stream](https://github.com/reactphp/stream).

```
$promise = $client->request($uri, $request);
$promise->then(
    function (ResponseInterface $response) {
        echo 'Successfully received a response from the server:' . PHP_EOL;
        echo RingCentral\Psr7\str($response);

        $body = $response->getBody();
        $body->on('data', function ($data) {
            echo "Body-Data: " . $data . PHP_EOL;
        });

        $body->on('end', function () {
            exit(0);
        });
    },
    function (\Exception $exception) {
        echo $exception->getMessage() . PHP_EOL;
    }
);
```

The `end`-Event will be emmitted when the complete body of the HTTP response has been transferred to the client. In the example above it will exit the current script.

### Request body

[](#request-body)

You can add also add a [ReactPHP Stream](https://github.com/reactphp/stream) as the request body to stream data with it. The body will always be transferred chunked encoded if you use this method, any header like `Content-Length` or other `Transfer-Encoding` headers will be replaced.

```
$stream = new ReadableStream();

$timer = $loop->addPeriodicTimer(0.5, function () use ($stream) {
    $stream->emit('data', array(microtime(true) . PHP_EOL));
});

$loop->addTimer(5, function() use ($loop, $timer, $stream) {
    $loop->cancelTimer($timer);
    $stream->emit('end');
});

$request = new Request(
    'POST',
    'http://127.0.0.1:10000',
    array(
        'Host' => '127.0.0.1',
        'Content-Type' => 'text/plain'
    ),
    $stream
);
$promise = $client->request($uri, $request);
```

This example will transfer every 0.5 seconds a chunked encoded data to the server. The transmission of the body will end after 5 seconds.

Checkout the `examples` folder to try it yourself.

Install
-------

[](#install)

[New to Composer?](https://getcomposer.org/doc/00-intro.md)

This will install the latest supported version:

```
$ composer require legionth/http-client-react:^0.1
```

License
-------

[](#license)

MIT

###  Health Score

26

—

LowBetter than 40% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity59

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 ~393 days

Total

2

Last Release

2889d ago

Major Versions

v0.1.0 → v1.1.02018-09-15

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1578709?v=4)[Niels Theen](/maintainers/legionth)[@legionth](https://github.com/legionth)

---

Top Contributors

[![legionth](https://avatars.githubusercontent.com/u/1578709?v=4)](https://github.com/legionth "legionth (18 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/legionth-http-client-react/health.svg)

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

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

43.5k344.8k1](/packages/ccxt-ccxt)[friendsofphp/php-cs-fixer

A tool to automatically fix PHP code style

13.5k257.0M27.8k](/packages/friendsofphp-php-cs-fixer)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136411.0k14](/packages/rector-rector-src)[team-reflex/discord-php

An unofficial API to interact with the voice and text service Discord.

1.1k434.3k26](/packages/team-reflex-discord-php)[react/http

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

78028.1M487](/packages/react-http)[nightowl/agent

NightOwl monitoring agent — collects telemetry from laravel/nightwatch and writes to PostgreSQL

915.8k](/packages/nightowl-agent)

PHPackages © 2026

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