datto/json-rpc
Composer 安装命令:
composer require datto/json-rpc
包简介
Fully unit-tested JSON-RPC 2.0 for PHP
README 文档
README
Overview
This package allows you to create and evaluate JSON-RPC messages, using your own PHP code to evaluate the requests.
This package allows you to create and evaluate any JSON-RPC message. It implements the JSON-RPC specifications, but does not provide a transport layer—which you'll also need if you want to send or receive messages over a distance! One of the beautiful features of JSON-RPC is that you can use any transport layer to carry your messages: This package gives you that option.
If you're looking for an end-to-end solution, with the transport layer included, then you should use one of these alternative packages instead:
- To send messages over HTTP(S), use the php-json-rpc-http package.
- To send messages over SSH, use the php-json-rpc-ssh package.
Features
- Correct: fully compliant with the JSON-RPC 2.0 specifications (100% unit-test coverage)
- Flexible: you can use your own code to evaluate the JSON-RPC method strings
- Minimalistic: extremely lightweight
- Ready to use, with working examples
Examples
Client
$client = new Client(); $client->query(1, 'add', array(1, 2)); $message = $client->encode(); // message: {"jsonrpc":"2.0","method":"add","params":[1,2],"id":1}
Server
$api = new Api(); $server = new Server($api); $reply = $server->reply($message); // reply: {"jsonrpc":"2.0","result":3,"id":1}
See the examples folder for full working examples.
Requirements
- PHP >= 7.0
License
This package is released under an open-source license: LGPL-3.0
Installation
If you're using Composer, you can include this library (datto/json-rpc) like this:
composer require "datto/json-rpc"
Getting started
-
Try the examples. You can run the examples from the project directory like this:
php examples/client.php php examples/server.php -
Take a look at the code "examples/src"—then replace it with your own!
Unit tests
You can run the suite of unit tests from the project directory like this:
./vendor/bin/phpunit
Changelog
See what has changed: Changelog
Author
datto/json-rpc 适用场景与选型建议
datto/json-rpc 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.32M 次下载、GitHub Stars 达 195, 最近一次更新时间为 2015 年 05 月 22 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rpc」 「php」 「json」 「json-rpc」 「jsonrpc」 「php-json-rpc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 datto/json-rpc 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 datto/json-rpc 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 datto/json-rpc 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Microservice RPC through message queues.
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
Get wordpress nav menus and share the main site menus with the child sites.
统计信息
- 总下载量: 1.32M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 197
- 点击次数: 28
- 依赖项目数: 13
- 推荐数: 0
其他信息
- 授权协议: LGPL-3.0
- 更新时间: 2015-05-22