PHPackages                             webguosai/hyperf-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. webguosai/hyperf-http-client

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

webguosai/hyperf-http-client
============================

hyperf http客户端

0193PHP

Since Jul 26Pushed 9mo agoCompare

[ Source](https://github.com/webguosai/hyperf-http-client)[ Packagist](https://packagist.org/packages/webguosai/hyperf-http-client)[ RSS](/packages/webguosai-hyperf-http-client/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

hyperf http client
==================

[](#hyperf-http-client)

[![Latest Stable Version](https://camo.githubusercontent.com/bf70f6820cb35e812bb1addb2b3addbee478b4b9154aa654d20e5f8652078c7e/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f6879706572662d687474702d636c69656e742f762f737461626c65)](https://packagist.org/packages/webguosai/hyperf-http-client)[![Total Downloads](https://camo.githubusercontent.com/998d7e1138b628d4b67bafd0e5d3235edb4e62ccb2c775a13532f5e4be24f330/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f6879706572662d687474702d636c69656e742f646f776e6c6f616473)](https://packagist.org/packages/webguosai/hyperf-http-client)[![Latest Unstable Version](https://camo.githubusercontent.com/f0bc799454b555deadf92c499c9fb0a034eee7cc606adbf750750d88b6cbc42f/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f6879706572662d687474702d636c69656e742f762f756e737461626c65)](https://packagist.org/packages/webguosai/hyperf-http-client)[![License](https://camo.githubusercontent.com/0da843d672cfc46cdfdae7909297557fa8b00a5d8489450eddfe63d9bdeb4e57/68747470733a2f2f706f7365722e707567782e6f72672f77656267756f7361692f6879706572662d687474702d636c69656e742f6c6963656e7365)](https://packagist.org/packages/webguosai/hyperf-http-client)

运行环境
----

[](#运行环境)

- php &gt;= 8.1
- composer
- hyperf &gt;= 3.1

安装
--

[](#安装)

```
composer require webguosai/hyperf-http-client -vvv
```

配置
--

[](#配置)

### 发布配置

[](#发布配置)

```
php bin/hyperf.php vendor:publish webguosai/hyperf-http-client
```

配置文件

```
return [
    // 超时 (单位秒，-1表示不超时)
    'timeout'       => 3.0,

    // 代理ip
    // http：127.0.0.1:9527 或 http://127.0.0.1:9527
    // https：https://127.0.0.1:9527
    // socks5：socks5://127.0.0.1:9527
    'proxy'         => '',

    // 重定向 (-1表示无限制，默认不重定向)
    'redirect'      => 0,

    // 保存cookie的文件路径
    'cookieJarFile' => '',
];
```

使用
--

[](#使用)

### 发送请求

[](#发送请求)

- **写法一**

```
use Webguosai\HyperfHttpClient\Facade\HttpClient;

// facade 写法
$response = HttpClient::request($url, $method, $data, $headers);

$response = HttpClient::get($url, $query, $headers);
$response = HttpClient::post($url, $data, $headers);
$response = HttpClient::put($url, $data, $headers);
$response = HttpClient::patch($url, $data, $headers);
$response = HttpClient::delete($url, $data, $headers);
$response = HttpClient::head($url, $data, $headers);
$response = HttpClient::options($url, $data, $headers);
```

- **写法二**

```
use function \Webguosai\HyperfHttpClient\http;

$response = http()->request($url, $method, $data, $headers);

$response = http()->get($url, $query, $headers);
$response = http()->post($url, $data, $headers);
$response = http()->put($url, $data, $headers);
$response = http()->patch($url, $data, $headers);
$response = http()->delete($url, $data, $headers);
$response = http()->head($url, $data, $headers);
$response = http()->options($url, $data, $headers);
```

- **写法三**

```
/** @var $http \Webguosai\HttpClient\Contract\HttpClientInterface * */
$http = di(\Webguosai\HttpClient\Contract\HttpClientInterface::class);

$response = $http->request($url, $method, $query, $headers);
$response = $http->get($url, $query, $headers);
$response = $http->post($url, $data, $headers);
$response = $http->put($url, $data, $headers);
$response = $http->patch($url, $data, $headers);
$response = $http->delete($url, $data, $headers);
$response = $http->head($url, $data, $headers);
$response = $http->options($url, $data, $headers);
```

### 实操

[](#实操)

```
/** @var $throw \Webguosai\HttpClient\Exception\RequestException **/
[$status, $throw] = $response->ok();
if ($status) {
    var_dump($response->getBody());
    var_dump($response->json());
} else {
    var_dump($throw->getMessage()); // 错误内容
    var_dump($throw->getRequestArgs()); // 请求前的传参
    var_dump($throw->getContext()); // 上下文 信息
    var_dump($throw->getErrorType()); // 错误类型
    var_dump($throw->getHttpStatusCode()); // http 状态码
    var_dump($throw->getCurlErrorCode()); // curl 错误码
}
```

文档
--

[](#文档)

License
-------

[](#license)

MIT

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance41

Moderate activity, may be stable

Popularity11

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/79b27387fc59b6ba29854bad71e11e6f7269534da234243353c5ec876bf9af5a?d=identicon)[json.](/maintainers/json.)

---

Top Contributors

[![webguosai](https://avatars.githubusercontent.com/u/2083784?v=4)](https://github.com/webguosai "webguosai (5 commits)")

---

Tags

guzzlehttphttpclienthyperf

### Embed Badge

![Health badge](/badges/webguosai-hyperf-http-client/health.svg)

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

###  Alternatives

[friendsofsymfony/rest-bundle

This Bundle provides various tools to rapidly develop RESTful API's with Symfony

2.8k73.3M317](/packages/friendsofsymfony-rest-bundle)[php-http/discovery

Finds and installs PSR-7, PSR-17, PSR-18 and HTTPlug implementations

1.3k309.5M1.2k](/packages/php-http-discovery)[nyholm/psr7

A fast PHP7 implementation of PSR-7

1.3k235.4M2.4k](/packages/nyholm-psr7)[pusher/pusher-php-server

Library for interacting with the Pusher REST API

1.5k94.8M292](/packages/pusher-pusher-php-server)[spatie/crawler

Crawl all internal links found on a website

2.8k16.3M52](/packages/spatie-crawler)[react/http

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

78126.4M414](/packages/react-http)

PHPackages © 2026

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