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

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

fastgoo/async-http-client
=========================

基于swoole扩展的HTTP异步请求扩展包，需要依赖swoole扩展

v1.2.0(8y ago)111653MITPHPPHP &gt;=7.0

Since Mar 18Pushed 8y ago2 watchersCompare

[ Source](https://github.com/fastgoo/AsyncHttpClient)[ Packagist](https://packagist.org/packages/fastgoo/async-http-client)[ Docs](https://phalcon.fastgoo.net)[ RSS](/packages/fastgoo-async-http-client/feed)WikiDiscussions master Synced yesterday

READMEChangelog (5)Dependencies (1)Versions (6)Used By (0)

基于Swoole扩展的HTTP异步客户端
====================

[](#基于swoole扩展的http异步客户端)

[![Latest Version](https://camo.githubusercontent.com/375ca592f70ce82bf78faf22ca4cc8aa352ce4533589ab40ddd2be229c9369a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f72656c656173652d76312e302e302d677265656e2e7376673f6d61784167653d32353932303030)](https://github.com/fastgoo/AsyncHttpClient/releases)[![Php Version](https://camo.githubusercontent.com/5127919eba34cfd4efa2e1d76a62f25de4061ec0a31a434fd9b23f6b16fc2c0e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d2533453d372e302d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://secure.php.net/)[![Swoole Version](https://camo.githubusercontent.com/c3e2e3a6cf5878641556c999c2f7c616b058ca49f5ba0838f1634b7e7d56cef5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73776f6f6c652d2533453d312e392d627269676874677265656e2e7376673f6d61784167653d32353932303030)](https://github.com/swoole/swoole-src)

简介
==

[](#简介)

基于 Swoole 异步客户端的扩展包，可以像使用 GuzzleHttp 简单优雅的使用swoole的异步客户端，无需关注底层实现以及处理逻辑。可实现同时发起N个HTTP请求不会被阻塞。经测试循环并发100个请求，全部返回结果只需要3-4秒的时间。

- 基于 Swoole 扩展
- 需在CLI模式下运行
- 支持HTTPS 与 HTTP 2种协议
- 使用 HTTPS 必须在编译swoole时启用--enable-openssl
- 解决高并发请求（可做接口压测）
- 异步 HTTP 请求，非阻塞
- 该扩展适用于目前所有现代框架
- 作者qq 773729704、微信 huoniaojugege 加好友备注github

更新记录
====

[](#更新记录)

- 2018.03.30 去掉get请求的参数，参数让用户自己带在URL上

参考文档
====

[](#参考文档)

[**中文文档**](https://wiki.swoole.com/wiki/page/p-http_client.html)

环境要求
====

[](#环境要求)

1. PHP 7.0 +
2. [Swoole 1.9](https://github.com/swoole/swoole-src/releases) +
3. [Composer](https://getcomposer.org/)

Composer 安装
===========

[](#composer-安装)

- `composer require fastgoo/async-http-client`

使用范例
====

[](#使用范例)

```
# ----------HTTP 请求（请求方式 get post put delete）--------
$client = new \AsyncClient\Client("https://open.fastgoo.net");
$params = [
    'address' => '邮箱',
    'subject' => '标题',
    'body' => '内容',
];

# 单请求
$client->post('/base.api/email/send', $params, function (\Swoole\Http\Client $client) {
    var_dump($client->body);
});

# 多请求
foreach (range(1, 50) as $v) {
    $client->post('/base.api/email/send', $params, function (\Swoole\Http\Client $client) {
        var_dump($client->body);
    });
}

# 发送请求文件
$client->setFiles(['files' => __DIR__ . '/fastgoo-logo.png'])->post('/base.api/file/upload',[],function (\Swoole\Http\Client $client) {
    var_dump($client->body);
})

# 开始发送请求
$client->send();
# -----------------------------END--------------------------

# 下载文件范例
$client = new \AsyncClient\Client("https://timgsa.baidu.com");
$client->download('/timg?image&quality=80&size=b9999_10000&sec=1521617943&di=913c0898b55cf2992d6d5136013e98d2&imgtype=jpg&er=1&src=http%3A%2F%2Fimg.taopic.com%2Fuploads%2Fallimg%2F120727%2F201995-120HG1030762.jpg', './logoaa.png', function (\Swoole\Http\Client $client) {
    var_dump($client);
});
$client->send();

# 静态对象实例化请求
\AsyncClient\Client::init("https://open.fastgoo.net")->post('/base.api/email/send', [], function (\Swoole\Http\Client $client) {
    var_dump($client->body);
})->send();

# 请求设置Cookies 和 Headers
$client->setCookies([]);
$client->setHeaders([]);

# 重点强调，由于默认不设置ip会自动异步解析DNS取到IP然后才能创建客户端，
# 异步解析DNS需要在CLI的模式下才能使用
# 如果条件允许的情况下尽量存取IP然后去发起请求，不然调外部网络会造成请求阻塞，性能优势会有所下降
$client->setDnsIp('192.168.1.1');

```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

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

Total

5

Last Release

2954d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.1

v1.0.1PHP &gt;=7.0

### Community

Maintainers

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

---

Top Contributors

[![fastgoo2](https://avatars.githubusercontent.com/u/160373799?v=4)](https://github.com/fastgoo2 "fastgoo2 (6 commits)")

---

Tags

httpasyncswoole

### Embed Badge

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

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

###  Alternatives

[hhxsv5/laravel-s

🚀 LaravelS is an out-of-the-box adapter between Laravel/Lumen and Swoole.

3.9k676.0k10](/packages/hhxsv5-laravel-s)[react/http

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

78126.4M414](/packages/react-http)[amphp/http-server

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

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

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

1.3k2.1M84](/packages/swow-swow)[amphp/http-client

An advanced async HTTP client library for PHP, enabling efficient, non-blocking, and concurrent requests and responses.

7286.8M137](/packages/amphp-http-client)[amphp/websocket-client

Async WebSocket client for PHP based on Amp.

1613.0M39](/packages/amphp-websocket-client)

PHPackages © 2026

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