veejay / jsonrpc
JSONRPC server and client
Installs: 8
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/veejay/jsonrpc
Requires
- php: >=7.2.0
- ext-json: *
Requires (Dev)
- codeception/codeception: ^4.1
- codeception/module-asserts: ^1.0.0
This package is auto-updated.
Last update: 2025-10-23 04:45:17 UTC
README
Jsonrpc 2.0 for PHP over HTTP(S).
Examples
Server
At first you have to extend veejay\jsonrpc\Api class and add required methods:
class MyApi extends Api { public function myMethod(array $params) { extract($params); if (!isset($myParam)) { throw new Exception(Response::INVALID_PARAMS); } return 'some result with param: ' . $myParam; } }
Then run Server with the following code:
$server = new Server(new MyApi); echo $response = $server->run();
Client
$client = new Client('https://jsonrpc/server/address'); $query = $client->query('myMethod', ['my_param' => 1]); $client->notify('myMethod'); $client->send();
You will receive the response from myMethod in $query variable.
Requirements
- PHP 7.2+
Installation
composer require "veejay/jsonrpc"