- Fully compliant with the JSON-RPC 2.0 specifications (with 100% unit-test coverage)
- Flexible: you can use your own code to evaluate the JSON-RPC methods
- Ultra-lightweight
- PHP >= 5.3
This package is released under an open-source license: LGPL-3.0
$client = new Client();
$client->query(1, 'add', array(1, 2));
$message = $client->encode(); // {"jsonrpc":"2.0","id":1,"method":"add","params":[1,2]}
$server = new Server(new Api());
$reply = $server->reply($message); // {"jsonrpc":"2.0","id":1,"result":3}
See the "examples" folder for ready-to-use examples.
If you're using Composer, you can use this package (datto/json-rpc) by inserting a line into the "require" section of your "composer.json" file:
"datto/json-rpc": "~3.0"
-
Try the examples. You can run the examples from the project directory like this:
php examples/client.php php examples/server.php
-
Take a look at the code "examples/src"--then replace it with your own!
You can run the suite of unit tests from the project directory like this:
./vendor/bin/phpunit