sajya/client
Composer 安装命令:
composer require sajya/client
包简介
HTTP client and server for JSON-RPC 2.0
README 文档
README
This package lets you set up a JSON-RPC client over HTTP(S), using your PHP code to make the requests. Built around Laravel (Doesn't require the entire framework, just its component) expressive HTTP wrapper, it allows you to customize things like authorization, retries, and more.
Install
Go to the project directory and run the command:
$ composer require sajya/client
Usage
use Illuminate\Support\Facades\Http; use Sajya\Client\Client; $client = new Client(Http::baseUrl('http://localhost:8000/api/v1/endpoint')); $response = $client->execute('tennis@ping'); $response->result(); // pong
By default, the request identifier will be generated using the UUID, you can get it by calling the id() method
$response->id();
To get the result of an error, you need to call the error() method
$response->error();
Parameters
Example with positional parameters:
$response = $client->execute('tennis@ping', [3, 5]);
Example with named arguments:
$response = $client->execute('tennis@ping', ['end' => 10, 'start' => 1]);
Batch requests
Call several procedures in a single HTTP request:
$batchData = $client->batch(function (Client $client) { $client->execute('tennis@ping'); $client->execute('tennis@ping'); });
Notify requests
$client->notify('procedure@method');
License
The MIT License (MIT). Please see License File for more information.
sajya/client 适用场景与选型建议
sajya/client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.01M 次下载、GitHub Stars 达 21, 最近一次更新时间为 2022 年 07 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rpc」 「api」 「json-prc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 sajya/client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 sajya/client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 sajya/client 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Easy implementation of the JSON-RPC 2.0 server for the Laravel framework.
Microservice RPC through message queues.
A PSR-7 compatible library for making CRUD API endpoints
Easy implementation of the JSON-RPC 2.0 server for the Laravel framework.
Control Nginx as a reverse proxy through plinker RPC
A API library that make it easy to access the Webuntis JSON RPC 2.0 API
统计信息
- 总下载量: 1.01M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 21
- 点击次数: 23
- 依赖项目数: 1
- 推荐数: 3
其他信息
- 授权协议: MIT
- 更新时间: 2022-07-08