hypervel / guzzle
Hypervel's fork of Guzzle, a PHP HTTP client library
Requires
- php: ^8.4
- ext-json: *
- ext-swoole: *
- guzzlehttp/psr7: ^3.1
- hypervel/guzzle-promises: ^3.0.2
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- symfony/polyfill-php80: ^1.25
- symfony/polyfill-php82: ^1.27
Requires (Dev)
- ext-curl: *
- bamarni/composer-bin-plugin: ^1.8.2
- guzzle/client-integration-tests: 4.0.1
- guzzlehttp/test-server: ^1.0.1
- php-http/message-factory: ^1.1
- phpunit/phpunit: ^9.6.34
- psr/log: ^1.1 || ^2.0 || ^3.0
Suggests
Provides
Conflicts
None
Replaces
- guzzlehttp/guzzle: 8.2.0.1
README
Guzzle, PHP HTTP Client
This is Hypervel's fork of Guzzle for Swoole coroutines. It replaces
guzzlehttp/guzzle and adds coroutine ownership checks and global middleware.
See Hypervel Fork.
Guzzle is a PHP HTTP client that makes it easy to send HTTP requests and trivial to integrate with web services.
- Simple interface for building query strings, POST requests, streaming large uploads, streaming large downloads, using HTTP cookies, uploading JSON data, etc...
- Can send both synchronous and asynchronous requests using the same interface.
- Uses PSR-7 interfaces for requests, responses, and streams. This allows you to utilize other PSR-7 compatible libraries with Guzzle.
- Supports PSR-18, allowing interoperability with other PSR-18 HTTP clients.
- Abstracts away the underlying HTTP transport, allowing you to write environment and transport agnostic code; i.e., no hard dependency on cURL, PHP streams, sockets, or non-blocking event loops.
- Middleware system allows you to augment and compose client behavior.
Hypervel Fork
Hypervel runs many Swoole coroutines in one long-lived PHP process. A cURL multi handler that one coroutine is driving must not be driven by another, and framework integrations need to see the requests of every Guzzle client, including clients that SDKs create. This fork adds:
- Multi handler ownership. A
CurlMultiHandlerwith pending work belongs to the coroutine driving it. Until the handler is idle, other coroutines can't send requests through it, tick, run or close it, or wait on or cancel its transfers: those calls throw aLogicExceptionwithout changing the handler. See Coroutine Ownership. - Transfer tracking. When the promise task queue implements
ScopedTaskQueueInterfacefromhypervel/guzzle-promises, the multi handler passes each pending transfer to it, so the queue can cancel transfers that a coroutine leaves unfinished when it ends. - Global middleware.
Client::pushGlobalMiddleware()andClient::removeGlobalMiddleware()manage named middleware that wraps the transfers of every client in the process. See Global Middleware. - More idle cURL handles.
CurlHandlerkeeps up to 256 idle easy handles by default instead of 3. Coroutines overlap synchronous requests on one handler, and each easy handle has its own connection cache, so with 3 most concurrent requests would open new connections.CurlMultiHandlerkeeps its default of 50. See Idle cURL Handles. - Upstream pull requests. The fork includes these changes from upstream pull
requests:
- #3934: keeps
StreamHandlerdeadlines local to each request. - #3935: adds the
max_idle_handlesoption for the cURL handlers. - #3936: returns available bytes from filtered streamed responses instead of waiting for a full buffer.
- #3937: reads
StreamHandlerresponse headers from the opened stream, which also fixes the stream handler under Swoole on PHP 8.4 and newer.
- #3934: keeps
Important
This fork keeps upstream's public API. Once installed, it replaces
guzzlehttp/guzzle for packages with compatible version requirements,
including third-party packages and SDKs, so their existing code keeps working
unchanged. Changes to the fork must stay backward compatible.
Installation
The recommended way to install Guzzle is through Composer.
composer require hypervel/guzzle
Version Guidance
This fork requires PHP 8.4 or newer and the Swoole extension.
composer.json lists the exact requirements. Each fork version
is the upstream release it is based on plus a fork release number. For example,
8.2.0.1 is the first fork release based on upstream 8.2.0.
Quick Start
$client = new \GuzzleHttp\Client(); $response = $client->request('GET', 'https://api.example.com/users/123'); echo $response->getStatusCode(); // 200 echo $response->getHeaderLine('content-type'); // 'application/json' echo $response->getBody(); // '{"id": 123, "name": "Ada"}'
For more examples, see the Quick Start.
Documentation
- Quick Start
- Overview
- Request Options
- Uploading Data
- Cookies
- Exceptions
- Guzzle and PSR-7
- Handlers
- Middleware
- Testing Guzzle Clients
- FAQ
- Package Ecosystem
- Upgrade Guide
- Changelog
For support questions, ideas, and feature requests, please use GitHub Discussions.
Security
If you discover a security vulnerability in this fork, please report it
privately by emailing Albert Chen at
albert@hypervel.org. Please do not report security
vulnerabilities through public GitHub issues or discussions. If it also affects
guzzlehttp/guzzle, please report it upstream as well through their
Security Policy.
License
Guzzle is made available under the MIT License (MIT). Please see License File for more information.
