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

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

xd/async-http
=============

v1.0.1(8y ago)2131MITPHPPHP &gt;=5.5.0

Since Dec 11Pushed 8y ago1 watchersCompare

[ Source](https://github.com/ganxiangdong/async-http-client)[ Packagist](https://packagist.org/packages/xd/async-http)[ Docs](https://github.com/ganxiangdong/async-http-client)[ RSS](/packages/xd-async-http/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)DependenciesVersions (3)Used By (1)

AsyncHttp is a very simple and agile HTTP asynchrony request library.

### Install

[](#install)

---

composer require xd/async-http

### Examples

[](#examples)

---

1. GET：

    ```
    //requsting
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3")->request();

    //do somthing...

    //get response
    $response = $req->getResponse();
    //get body
    $resBody = $response->body;
    //get http status code
    $httpStatusCode = $response->statusCode;
    //get response all header
    $headers = $response->headers;
    //get one header
    $header = $response->getHeader('Server');
    ```
2. POST

    ```
    //requesting by x-www-form-urlencode
    $postData = ['sleepTime' => 3];
    $req = AsyncHttp::post("http://192.168.88.2", $postData)->request();
    //requesting by raw JSON
    $postData = json_encode(['sleepTime' => 1]);
    $req2 = AsyncHttp::post("http://192.168.88.2", $postData)->request();
    //requesting by raw XML
    $req2 = AsyncHttp::post("http://192.168.88.2", $xmlDataStr)
      ->addHeader("Content-Type":"application/xml")->request();

    //do somthing...

    //get response
    $body1 = $req->getResponse()->body;
    $body2 = $req2->getResponse()->body;
    $body3 = $req3->getResponse()->body;
    ```
3. PUT

    ```
    //requesting by x-www-form-urlencode
    $putData = json_encode(['sleepTime' => 3]);
    $req = AsyncHttp::put("http://192.168.88.2/index.php", $putData)->request();
    //requesting by raw JSON
    $putData = json_encode(['sleepTime' => 1]);
    $req2 = AsyncHttp::put("http://192.168.88.2/index.php", $postData)->request();

    //do somthing...

    //get response
    $body1 = $req->getResponse()->body;
    $body2 = $req2->getResponse()->body;
    ```
4. DELETE

    ```
    //requesting
    $req = AsyncHttp::delete("http://192.168.88.2/index.php?sleepTime=3")->request();
    //requesting
    $req2 = AsyncHttp::delete("http://192.168.88.2/index.php?sleepTime=0")->request();

    //do somthing...

    //get response
    $body1 = $req->getResponse()->body;
    $body2 = $req2->getResponse()->body;
    ```

### Other usage

[](#other-usage)

---

1. Custom header

    ```
    //example 1
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3");
    $req->addHeader("Test", 1);
    $req->request();

    //example 2
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3")->addHeader("Test", 1)->addHeader("Test-X", "2")->request();

    //example 3
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3");
    $req->requestHeaders = ["Test" => "1","Test-X" => "2"];
    $req->request();
    ```
2. Set timeout（default 8 second）

    ```
    //example 1
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3");
    $req->setTimeout(8);
    $req->request();

    //example 2
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3")->setTimeout(8)->request();

    //example 3
    $req = AsyncHttp::get("http://192.168.88.2?sleepTime=3");
    $req->setTimeout = 8;
    $req->request();
    ```
3. How to judge timeout or network unreachable

    ```
    if ($response->getStatusCode() == 0) {

    }

    ```

    ​

###  Health Score

26

—

LowBetter than 43% 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 ~0 days

Total

2

Last Release

3077d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35f6ecb0480c9da5906a1898cd98623503e4a067e96145f3c6366249c635666a?d=identicon)[ganxiangdong](/maintainers/ganxiangdong)

---

Top Contributors

[![ganxiangdong](https://avatars.githubusercontent.com/u/10627214?v=4)](https://github.com/ganxiangdong "ganxiangdong (9 commits)")

---

Tags

asynchttp clientasynchronismasyncHttpasyncHttpClient

### Embed Badge

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

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

###  Alternatives

[psr/http-client

Common interface for HTTP clients

1.7k680.7M2.1k](/packages/psr-http-client)[react/http

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

78126.4M414](/packages/react-http)[kriswallsmith/buzz

Lightweight HTTP client

2.0k31.3M443](/packages/kriswallsmith-buzz)[amphp/http-server

A non-blocking HTTP application server for PHP based on Amp.

1.3k4.5M81](/packages/amphp-http-server)[smi2/phpclickhouse

PHP ClickHouse Client

83510.1M71](/packages/smi2-phpclickhouse)[swow/swow

Coroutine-based multi-platform support engine with a focus on concurrent I/O

1.3k2.1M84](/packages/swow-swow)

PHPackages © 2026

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