PHP code example of trifs / jsonrpc

1. Go to this page and download the library: Download trifs/jsonrpc 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/ */

    

trifs / jsonrpc example snippets


{
    "  "trifs/jsonrpc": "dev-master"
    }
}

$client = new trifs\jsonrpc\Client('http://example.com');
$client->request('method-one')
    ->send();

$client = new trifs\jsonrpc\Client('http://example.com');
$client->notification('method-one')
    ->send();

$client = new trifs\jsonrpc\Client('http://example.com');
$client->request('method-one')
    ->request('method-two')
    ->notification('method-three')
    ->send();

$client = new trifs\jsonrpc\Client(
    'http://example.com',
    ['timeout' => 5, ]
);

$client->setTransporter(new trifs\jsonrpc\Client\Transporter\CurlTransporter());

$input   = file_get_contents('php://input');
$invoker = function($method, array $params = []) {
    return time();
};

$server = new trifs\jsonrpc\Server($input, $invoker);
$server->run();
shell
composer global 
shell
git clone git://github.com/3fs/php-json-rpc
cd php-json-rpc
vagrant up