$ composer require etk-pl/json-rpc
use JsonRpc\Client;
use JsonRpc\Request;
$client = new Client('http://localhost:8080/');
$response = $client->send(new Request([
'resource' => 'Test',
'method' => 'echo',
'params' => ['param' => 'value']
]));
if($error = $response->getError()) {
die("Got error: " . $error['message']);
}
$result = $response->getResult();
var_dump($result);
or
use JsonRpc\ApiClient;
$client = new ApiClient('http://localhost:8080/');
try{
$result = $client->Test->echo(['param' => 'value']);
} catch(\Exception $e) {
die("Got error: " . $error['message']);
}
var_dump($result);