datto / json-rpc-ssh
JSON-RPC 2.0 的 SSH 客户端和服务器
1.0.0
2015-05-22 20:04 UTC
Requires
- php: >=5.3.0
- datto/json-rpc: 1.0.*
This package is not auto-updated.
Last update: 2024-09-14 17:37:32 UTC
README
功能
- 完全符合 JSON-RPC 2.0 规范(100% 单元测试覆盖率)
- 灵活:您可以选择自己的系统来解析 JSON-RPC 方法字符串
- 简约(只有两个小巧的文件)
- 可直接使用,带有工作示例
要求
- PHP >= 5.3
许可证
本软件包是在开源许可证下发布的:LGPL-3.0
示例
客户端
$client = new Client($destination, $command, $options); $client->query(1, 'add', array(1, 2)); $reply = $client->send(); // array('jsonrpc' => '2.0', 'id' => 1, 'result' => 3)
服务器
$translator = new Translator(); $server = new Server($translator); $server->reply();
查看 "examples" 文件夹中的可直接使用的示例。
安装
如果您使用 Composer,您可以通过在 "composer.json" 文件的 "require" 部分中插入一行来使用此软件包(datto/json-rpc-ssh)
"datto/json-rpc-ssh": "~1.0"
入门指南
-
尝试示例!按照 "examples" 目录中的 README 文件设置 SSH 环境。然后像这样从项目目录中运行示例
php examples/client.php
-
一旦您的示例运行正常,将 示例 "服务器" 代码 替换为您自己的代码。
-
围绕 JSON-RPC 客户端类编写一个美观的包装器,使其与您的项目相匹配。