efabrica/revolt-curl-client
最新稳定版本:0.1.4
Composer 安装命令:
composer require efabrica/revolt-curl-client
包简介
Implementation of Symfony's HttpClientInterface that combines multicurl with Revolt's async EventLoop
README 文档
README
This is a fork of symfony/http-client's CurlClient that uses Revolt's async EventLoop to wait for the response instead of blocking the
main thread.
This client was created because native PHP streams that are used by amphp/http-client are slow, as our applications were hanging on
stream_select() a lot but they weren't hanging on curl_multi_select(). Reasons for this are unknown to us, but if you know,
please share your knowledge and we will place it in this README.
It uses Symfony's @internal classes, so it might break on minor Symfony versions. We will rush to fix it if it does.
Installation
composer require efabrica/revolt-curl-client
Usage
use Efabrica\RevoltCurlClient\RevoltCurlClient; $client = new RevoltCurlClient(); $f1 = async(function () use ($client) { echo "Request 1\n"; $response = $client->request('GET', 'https://httpbin.org/get?1'); $response->getContent(); echo "Request 2\n"; $response2 = $client->request('GET', 'https://httpbin.org/get?2'); $response2->getContent(); }); $f2 = async(function () use ($client) { echo "Request 3\n"; $response = $client->request('GET', 'https://httpbin.org/get?3'); $response->getContent(); echo "Request 4\n"; $response2 = $client->request('GET', 'https://httpbin.org/get?4'); $response2->getContent(); }); await([$f1, $f2]); // Outputs: // Request 1 // Request 3 // Request 2 // Request 4
统计信息
- 总下载量: 14.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: MIT
- 更新时间: 2024-08-21