bugbuster / tivoka
The universal JSON-RPC client/server library. JSON-RPC done right! Contao version
Installs: 4 570
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 2
Type:contao-module
Requires
- php: >=5.3
- contao/core: >=3.3.1,<4
- textalk/websocket: 1.0.*
Replaces
- contao-legacy/tivoka: 1.1.1
This package is auto-updated.
Last update: 2024-10-23 10:06:40 UTC
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.json
in 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.