bugbuster/tivoka
最新稳定版本:1.1.1
Composer 安装命令:
composer require bugbuster/tivoka
包简介
The universal JSON-RPC client/server library. JSON-RPC done right! Contao version
README 文档
README
JSON-RPC client and server for PHP 5.3+
Based on tivoka in version 3.4.0
- JSON-RPC client/server library for PHP (supports v1.0 and v2.0 specs)
- Easily switch between the v1.0 and v2.0 specs
- HTTP, TCP and Websocket transports available
- New: CurlHTTP available, used if HTTP not allowed (allow_url_fopen)
Examples
These are just some quick examples. Check out the docs in /doc/.
Do a request through HTTP...
<?php $connection = BugBuster\Tivoka\Client::connect('http://example.com/api') $request = $connection->sendRequest('substract', array(51, 9)); print $request->result;// 42 ?>
...or plain TCP
<?php $connection = BugBuster\Tivoka\Client::connect(array('host' => 'example.com', 'port' => 1234)) $request = $connection->sendRequest('substract', array(51, 9)); print $request->result;// 42 ?>
...or WebSocket
<?php $connection = BugBuster\Tivoka\Client::connect('ws://example.com/api') $request = $connection->sendRequest('substract', array(51, 9)); print $request->result;// 42 ?>
Create a server
<?php $methods = array( 'substract' => function($params) { list($num1, $num2) = $params return $num1 - $num2; } ); BugBuster\Tivoka\Server::provide($methods)->dispatch(); ?>
Installation
Install composer package
- Set up
composer.jsonin your project directory:
{
"require":{"bugbuster/tivoka":"*"}
}
- Run composer:
$ php composer.phar install
Now, include 'vendor/autoload.php'
License
Copyright 2011-2012 by Marcel Klehr, MIT License.
Copyright (c) 2014-2016 Glen Langer (Contao Version), MIT License.
统计信息
- 总下载量: 4.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-12-11