PHPackages                             mix/guzzle - 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. mix/guzzle

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

mix/guzzle
==========

Guzzle that support the Swoole coroutine

v2.2.17(4y ago)392.3k86Apache-2.0PHP

Since May 24Pushed 4y ago1 watchersCompare

[ Source](https://github.com/mix-php/guzzle)[ Packagist](https://packagist.org/packages/mix/guzzle)[ Docs](https://openmix.org/)[ RSS](/packages/mix-guzzle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (13)Used By (6)

注意：Swoole 已经推出内置 [SWOOLE\_HOOK\_NATIVE\_CURL](https://wiki.swoole.com/#/runtime?id=swoole_hook_native_curl)、[SWOOLE\_HOOK\_CURL](https://wiki.swoole.com/#/runtime?id=swoole_hook_curl) 功能，请使用官方提供的 Hook 功能，本项目将停止维护。

Mix Guzzle
----------

[](#mix-guzzle)

支持 Swoole 协程的 Guzzle, 可无感 Hook 第三方库，同时支持调低 PHP 错误级别

安装
--

[](#安装)

> 注意：安装后整个项目的 Guzzle 默认 CurlHandler 将会替换为该项目的 StreamHandler，实现了无感 Hook

使用 Composer 安装：

```
composer require mix/guzzle

```

使用
--

[](#使用)

根据 `Guzzle` 官方文档使用即可：

```
$client   = new \GuzzleHttp\Client();
$response = $client->get('https://www.baidu.com/');
```

也可以手动指定 `handler` 如下：

```
$handler = new \Mix\Guzzle\Handler\StreamHandler();
$stack   = \GuzzleHttp\HandlerStack::create($handler);
$client  = new \GuzzleHttp\Client([
    'handler'  => $stack,
]);
```

### `Elasticsearch PHP` 支持

[](#elasticsearch-php-支持)

> 安装后 GuzzleHttp\\Ring 的 CurlHandler 将会替换为该项目的 Ring\\StreamHandler，实现了无感 Hook

根据 [Elasticsearch PHP](https://github.com/elastic/elasticsearch-php) 官方文档使用即可：

```
use GuzzleHttp\Ring\Client\StreamHandler;
use Elasticsearch\ClientBuilder;

$handler = new StreamHandler();
$builder = ClientBuilder::create();
$builder->setHosts(['127.0.0.1:9200']);
$builder->setHandler($handler);
$client = $builder->build();
```

原理
--

[](#原理)

因为 Swoole 的 Hook 只支持 PHP Stream，Guzzle 库默认是使用 CURL 扩展，而 Swoole 不支持在协程中使用 CURL，因此本库将 Guzzle 默认的 CurlHandler 替换为 StreamHandler，并做了一些协程优化处理，让依赖 Guzzle 的第三方库无需修改代码即可使用 Swoole 协程。

支持的第三方库
-------

[](#支持的第三方库)

理论上基于 Guzzle 库开发的 SDK 都可使用本库 Hook，下面是已知的支持 Hook 的第三方库清单：

> 欢迎提交 PR 更新此清单

- [alibabacloud/client](https://github.com/aliyun/openapi-sdk-php-client)
- [TencentCloud/tencentcloud-sdk-php](https://github.com/TencentCloud/tencentcloud-sdk-php)
- [elastic/elasticsearch-php](https://github.com/elastic/elasticsearch-php)

License
-------

[](#license)

Apache License Version 2.0,

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity66

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

Recently: every ~104 days

Total

12

Last Release

1648d ago

Major Versions

v1.0.2 → v2.1.152020-03-30

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16074765?v=4)[LIU JIAN](/maintainers/onanying)[@onanying](https://github.com/onanying)

---

Top Contributors

[![onanying](https://avatars.githubusercontent.com/u/16074765?v=4)](https://github.com/onanying "onanying (23 commits)")

---

Tags

guzzlehookswooleGuzzleswoolecoroutinemix

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mix-guzzle/health.svg)

```
[![Health](https://phpackages.com/badges/mix-guzzle/health.svg)](https://phpackages.com/packages/mix-guzzle)
```

###  Alternatives

[hhxsv5/laravel-s

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

3.9k676.0k10](/packages/hhxsv5-laravel-s)[swlib/saber

Swoole coroutine HTTP client

985145.0k27](/packages/swlib-saber)[hyperf/hyperf

A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.

6.8k3.0k2](/packages/hyperf-hyperf)[graham-campbell/guzzle-factory

Provides A Simple Guzzle Factory With Good Defaults

916.4M49](/packages/graham-campbell-guzzle-factory)[simps/mqtt

MQTT Protocol Analysis and Coroutine Client for PHP

39351.6k9](/packages/simps-mqtt)[hyperf/guzzle

Swoole coroutine handler for guzzle

102.7M291](/packages/hyperf-guzzle)

PHPackages © 2026

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