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客户端

0199PHP

Since Jul 26Pushed 11mo 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

18

—

LowBetter than 8% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity10

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

[php-http/cache-plugin

PSR-6 Cache plugin for HTTPlug

25126.1M82](/packages/php-http-cache-plugin)[illuminate/http

The Illuminate Http package.

11937.9M6.9k](/packages/illuminate-http)[rdkafka/rdkafka

A PHP extension for Kafka

2.2k24.3k1](/packages/rdkafka-rdkafka)[httpsoft/http-message

Strict and fast implementation of PSR-7 and PSR-17

87965.9k114](/packages/httpsoft-http-message)[mezzio/mezzio-router

Router subcomponent for Mezzio

265.4M90](/packages/mezzio-mezzio-router)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69127.2k](/packages/serpapi-google-search-results-php)

PHPackages © 2026

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