mix / guzzle-hook
让 Guzzle 支持 Swoole 的 PHP Stream Hook 协程
Installs: 531
Dependents: 0
Suggesters: 0
Security: 0
Stars: 27
Watchers: 1
Forks: 3
Open Issues: 0
pkg:composer/mix/guzzle-hook
Requires
This package is auto-updated.
Last update: 2020-03-30 02:36:13 UTC
README
让 Guzzle 支持 Swoole 的 PHP Stream Hook 协程
安装
支持的 Guzzle 版本:
- guzzle-6.0
(>= 6.0.2)
- guzzle-6.1
- guzzle-6.2
- guzzle-6.3
- guzzle-6.4
使用 Composer 安装:
composer require mix/guzzle-hook
在项目的 composer.json
文件中增加 extra
配置项,如下:
"extra": {
"include_files": [
"vendor/mix/guzzle-hook/src/functions_include.php"
]
}
更新自动加载:
composer dump-autoload
原理
因为 Swoole 的 Hook 只支持 PHP Stream,Guzzle 库默认是使用 CURL 扩展,导致无法 Hook 为协程,本库修改了 Guzzle 的默认 Handler 为 StreamHandler,让依赖 Guzzle 的第三方库无需修改代码即可使用 Swoole 协程。
支持的第三方库
理论上基于 Guzzle 库开发的 SDK 都可使用本库 Hook,下面是已知的支持 Hook 的第三方库清单:
欢迎提交 PR 更新此清单
License
Apache License Version 2.0, http://www.apache.org/licenses/