xJsonRPC-PHP is a JSON-RPC library for PHP featuring a client (TODO) and a server. Currently it follows the 2.0 spec of JSON-RPC, including batch calls
There's currently 3 server implementations: Server, WebServer and StdInServer
Server
Base class, accepts a JSON string as argument to handle() that is processed as a JSON-RPC requestWebServer
Will attempt to read out php://input to get the JSON-RPC request, handle() should be called (without arguments) to make it start processingStdInServer
Does the same as WebServer except it uses php://stdin (command line, etc.) instead of php://input
To implement methods you subclass one of the above servers and add methods. These methods must be public in order to be allowed for server use.
Example
use \Textalk\JsonRpc\Server;
class ExampleServer extends Server
{
public function echo($echo)
{
return $echo;
}
}
$server = ExampleServer();
$response = $server->handle('{"id": 1, "method": "echo", "jsonrpc": "2.0", "params": ["hello world"]}');
TODO