fthvgb1 / gophpfetch
A php http request extension on concurrence writing in golang, use FFI to call
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/fthvgb1/gophpfetch
Requires
- php: >=8.1
- ext-ffi: *
- ext-mbstring: *
This package is auto-updated.
Last update: 2026-01-05 12:11:01 UTC
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






