devchunk/yii2-json-rpc

This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (v2.0.0) of this package.

yii2-json-rpc

v2.0.0 2016-07-07 21:36 UTC

This package is not auto-updated.

Last update: 2020-01-16 21:09:35 UTC


README

JsonRpc Server and Client for Yii2

##Usage Server

  1. Install with Composer
"require": {
    "devchunk/yii2-json-rpc": "dev-master",
},

php composer.phar update
  1. Server:

Add action to controller (e.g. JsonRpcTestController)

public function actions()
{
    return array(
        'index' => array(
            'class' => '\devchunk\jsonRpc\Action',
        ),
    );
}

public function echo($param) {
	return $param;
}
  1. Client:
$rpc = new Client('http://127.0.0.1/json-rpc-test', [
    'timeout' => 5,
]);

$result = $rpc->echo("some string");

echo sprintf("RPC result: %s\n", $r);