PHP code example of moaction / jsonrpc-server
1. Go to this page and download the library: Download moaction/jsonrpc-server library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
moaction / jsonrpc-server example snippets
$server = new \Moaction\Jsonrpc\Server\BasicServer();
$server->addMethod('getUser', function($id) {
return array(
'id' => $id,
'name' => 'UserName'
);
});
echo $server->run(file_get_contents('php://input'));
$server->addMethod('errorTest', function() {
throw new \Exception('Strange server error', 42);
});