mahelbir/mclient
Composer 安装命令:
composer require mahelbir/mclient
包简介
Simple async request wrapper for Guzzle
README 文档
README
Mclient acts as a straightforward asynchronous wrapper around Guzzle for making HTTP requests.
Requirements
PHP 7.1+
Installation
Simply add a dependency on mahelbir/mclient to your composer.json file if you
use Composer to manage the dependencies of your project:
composer require mahelbir/mclient
Although it's recommended to use Composer, you can actually include files anyway you want.
Usage
$mclient = new \Mahelbir\Mclient(); //Library options $mclient->setTimeout(10); // total seconds $mclient->setConnectTimeout(5); $mclient->setConcurrency(100); // Async multiple requests $mclient->request( 'GET', 'https://httpbin.org/get', ['X-CUSTOM-HEADER' => 'Value'], ['proxy' => '127.0.0.1:8080'], 'request_1_extra_data' ); $mclient->post( 'https://httpbin.org/post', ['key' => 'value'], ['User-Agent' => 'Googlebot'], ['allow_redirects' => false], 'request_2_extra_data' ); $mclient->post( 'https://httpbin.org/post', '{"key": "value"}', ['content-type' => 'application/json'] ); $mclient->get( 'https://httpbin.org/get?q=1', [], [], [], ['request_3_extra_data' => 'value_extra'] ); $mclient->get( 'https://httpbin.org/get', ["q" => 2] ); // Mclient supports all the request options available in Guzzle, with the addition of an 'interface' option (https://docs.guzzlephp.org/en/stable/request-options.html) $mclient->get('https://google.com', [], [], ['interface' => '2001:db8:3333:4444:5555:6666:7777:8888']); $responses = $mclient->execute(); foreach ($responses as $response) { $status = $response['code']; $body = $response['body']; $headers = $response['headers']; $request = $response['request']; $extra = $response['extra']; } // Pass true parameter to retrieve the first/single response $mclient->get('https://httpbin.org/get'); $response = $mclient->execute(true);
License
The MIT License (MIT). Please see License File for more information.
mahelbir/mclient 适用场景与选型建议
mahelbir/mclient 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 74 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 09 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 mahelbir/mclient 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mahelbir/mclient 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 74
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 10
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-09-08