[go: up one dir, main page]

Skip to content

raoptimus/yii2-jsonrpc2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Stable Version Untable Version License Total Downloads Build Status

yii2-jsonrpc2

Json RPC client 1.0 and 2.0 versions for Yii2

Installation

Install with composer:

composer require raoptimus/yii2-jsonrpc2

Usage samples

Configuration

return [
    //....
    'components' => 
        'jsonrpc' => [
            'class' => raoptimus\jsonrpc2\Connection::class,
            'hostname' => 'localhost',
            'port' => 8666,
        ],
];
return [
    //....
    'components' => 
        'jsonrpc' => [
            'class' => raoptimus\jsonrpc2\Connection::class,
            'unixSocket' => '/tmp/jsonrpc2.sock',
            'spec' => raoptimus\jsonrpc2\Connection::SPEC_2_0,
        ],
];

Use connection

$rpc = \Yii::$app->get('jsonrpc');
$method = "SomeMethodName";
$param = "SomeEnterParam";
$request = $rpc->createRequest($method, [$param]);
$rpc->sendRequest($request);
$result = $rpc->readResponse()->result;
//or
$result = $rpc->$method($param);