• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

doc/tutorial/H20-Oct-2016-287233

example/H20-Oct-2016-4029

lib/Tivoka/H20-Oct-2016-2,201852

.gitignoreH A D20-Oct-2016112 108

.travis.ymlH A D20-Oct-201667 76

LICENSEH A D20-Oct-20161.1 KiB2318

README.mdH A D20-Oct-20163.4 KiB157108

composer.jsonH A D20-Oct-2016573 2423

include.phpH A D20-Oct-20161,001 2924

README.md

1# Tivoka
2[JSON-RPC](http://jsonrpc.org/) client and server for PHP 5.3+
3
4* Easily switch between the [v1.0](http://json-rpc.org/wiki/specification) and [v2.0](http://jsonrpc.org/specification) specs
5* HTTP, TCP and Websocket transports available
6
7## Examples ##
8These are just some quick examples. Check out the docs in [`/doc/`](https://github.com/marcelklehr/tivoka/tree/develop/doc).
9
10Do a request through HTTP...
11```php
12<?php
13$connection = Tivoka\Client::connect('http://example.com/api')
14$request = $connection->sendRequest('substract', array(51, 9));
15print $request->result;// 42
16?>
17```
18
19...or plain TCP
20```php
21<?php
22$connection = Tivoka\Client::connect(array('host' => 'example.com', 'port' => 1234))
23$request = $connection->sendRequest('substract', array(51, 9));
24print $request->result;// 42
25?>
26```
27
28...or WebSocket
29```php
30<?php
31$connection = Tivoka\Client::connect('ws://example.com/api')
32$request = $connection->sendRequest('substract', array(51, 9));
33print $request->result;// 42
34?>
35```
36
37Create a server
38```php
39<?php
40$methods = array(
41    'substract' => function($params) {
42        list($num1, $num2) = $params
43        return $num1 - $num2;
44    }
45);
46Tivoka\Server::provide($methods)->dispatch();
47?>
48```
49
50## Links
51 - Have a look at the documentation in `doc/`
52 - Submit any bugs, suggestions or questions to the [issue tracker](http://github.com/marcelklehr/tivoka/issues)
53
54## Installation
55
56### Install composer package
571. Set up `composer.json` in your project directory:
58```
59{
60  "require":{"tivoka/tivoka":"*"}
61}
62```
63
642. Run [composer](http://getcomposer.org/doc/00-intro.md#installation):
65```sh
66$ php composer.phar install
67```
68
69Now, `include 'vendor/autoload.php'`
70
71## License ##
72Copyright 2011-2012 by Marcel Klehr
73MIT License.
74
75## Changelog ##
763.5.1
77
78 * Fix Http Connection
79
803.5.0
81
82 * Add support for cookies if curl is installed (thanks to @oxan)
83
843.4.2
85
86 * Fix HTTP via curl: Don't add a trailing newline for http headers (thanks to @oskarcafe)
87
883.4.1
89
90 * Http: Use cURL if available (thanks to @hschletz)
91
923.4.0
93
94 * Adding options to set/override request headers in WebSocket (thanks to @fiddur)
95
963.3.0
97
98 * Add websocket transport (thanks to @fiddur)
99
1003.2.1
101
102 * Fix #41: Fix Exception catcher in Tivoka\Server\Server::process (thanks to @ikulis)
103
1043.2.0
105
106 * Feature: Plain TCP connections (revamped a lot of our internals along the way! thanks go out to @rafalwrzeszcz)
107 * Feature: Configurable connection timeout
108
1093.1.0
110
111 * Fix #27: json-rpc response[result] may be `null` (thanks to @vaab)
112 * Feature: Allow setting of request headers and expose response headers (thanks to @vaab)
113 * Fix bug with client-side notifications
114 * Add docs in `doc/`
115
1163.0.1
117
118 * Fix a typo, that used to screw up things when throwing an exception (thanks to @gahr)
119
120
1213.0.0
122
123 * use Namespaces (no longer supports php5.2)
124 * new factory classes (per server/client)
125 * Requests no longer require $id argument
126 * Dramatically simplified serverside usage
127 * Fluid spec version setter
128 * Now available as composer package
129
130
1312.0.3
132
133 * Added HTTPS support
134 * target scheme is now treated case insensitive
135
136
1372.0.2
138
139 * Introduced new directory structure
140 * Fixed #10
141 * Some Exception messages changed slightly to be more specific
142
143
1442.0.1
145
146 * Patched http method spelling (make uppercase, so all servers accept it)
147
148
1492.0.0
150
151 * complete Code base rework
152 * major API change
153 * removed Response Class
154 * Added aa number of shortcuts
155 * Implemented native remote interface
156
157