raoptimus/yii2-jsonrpc2

Json-rpc2 protocol for Yii2 Framework

Installs: 233

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 3

Forks: 0

Open Issues: 0

Type:yii2-extension

1.0.3 2018-10-13 14:36 UTC

This package is auto-updated.

Last update: 2024-12-15 06:00:03 UTC


README

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);