fthvgb1/gophpfetch
最新稳定版本:v1.0.2
Composer 安装命令:
composer require fthvgb1/gophpfetch
包简介
A php http request extension on concurrence writing in golang, use FFI to call
README 文档
README
a php http request extension on concurrence writing in golang
use FFI to call golang http requests with concurrence.
install
- add follow contents to project's composer.json and run
composer install && composer run-script downloadExtension.
{
"require": {
"fthvgb1/gophpfetch": "*"
},
"scripts": {
"downloadExtension": [
"@putenv COMPOSER=vendor/fthvgb1/gophpfetch/composer.json",
"@composer downloadExtension"
]
}
}
to avoid including the unnecessary others platform's extension files, you need to download extension file manually in release.
- enable ffi extension add follow config to php.ini or ffi.ini to using in php-fpm
extension=ffi.so
ffi.enable=true
example
$results = Fetch::fetch([ [ 'url' => 'url', 'method' => 'get',//default 'id' => 'get request', 'query' => ['query param' => 'values'] ], [ 'url' => 'url', 'id' => 'post request', 'body' => ['post body param' => 'values'], 'header' => [ 'Content-Type' => PostType::FormUrlencoded, //default post type ] ], [ 'url' => 'download url', 'method' => 'get', 'query' => ['query param' => 'value'], 'id' => 'dowload file', 'saveFile' => [ 'path' => 'save path', 'mode' => '0644', //default 'dirMode '=> '0755' //default ] ], [ 'url' => 'upload url', 'method' => 'post', 'id' => 'upload file', 'header' => ['Content-Type' => PostType::FormData], 'body' => [ '__uploadFiles' => [ 'local file' => 'field' ] ] ] ]);
performance comparison
upload 5 files and download 5 files in a request on concurrence
results:
| gophpfetch | multiple curl | swoole curl | |
|---|---|---|---|
| xdebug |
|
|
![]() |
| xhprof | ![]() |
||
![]() |
![]() |
![]() |
|
test method and scripts see here
reference
统计信息
- 总下载量: 7
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-09-23






