Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/xujif/php-json-rpc
json-rpc base on guzzle
https://github.com/xujif/php-json-rpc
Last synced: 17 days ago
JSON representation
json-rpc base on guzzle
- Host: GitHub
- URL: https://github.com/xujif/php-json-rpc
- Owner: xujif
- License: mit
- Created: 2017-02-09T03:27:43.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-05-04T07:06:59.000Z (over 7 years ago)
- Last Synced: 2024-12-01T16:18:40.429Z (22 days ago)
- Language: PHP
- Size: 10.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
#json-rpc base on guzzle
a full json-rpc 2.0 [RFC](http://www.jsonrpc.org/specification) implementation###Usage
####Server
```php
/*
* in any http framworks
*/
$apiObject = new Api();
$server = new \Xujif\JsonRpc\Server($apiObject);
// return array
// please return to client with json
$ret = $server->handle();
header('Content-Type:application/json')
echo json_encode($ret);
```####Client
```php
$client = new \Xujif\JsonRpc\Client('API_SERVER_URL');
$client->call('method',[1,2,3]);
// or
$client->method(1,2,3)
// or notification(no result send async)
$client->notify()->method(1,2,3)
// or batch call
$client->batch()->method(1,2,3)->method2(1,2)->exec();
// or batch notification
$client->batch()->notify()->method(1,2,3)->method2(1,2)->exec();
// or batch mixed notification and call
// if all batch call is notify it will send async
$client->batch()
->notify()
->method(1,2,3)
->notify(false)
->method2(1,2)
->exec();```