nizsheanez/yii2-json-rpc

A lightweight JsonRpc Server and Client for PHP

Installs: 1 062

Dependents: 0

Stars: 8

Watchers: 3

Forks: 11

Language: PHP

v1.1.5 2015-04-05 02:55 UTC

README

JsonRpc Server and Client for Yii2

1) Install with Composer

"require": {
    "nizsheanez/yii2-json-rpc": "1.*",
},

php composer.phar update

2) Add action to controller

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

public function sum($a, $b) {
    return $a + $b;
}

3) All methods of controller now available as JsonRpc methods, for example see method sum:

Usage Client

$client = new \nizsheanez\JsonRpc\Client('http://url/of/webservice');

$response = $client->sum(2, 3);
echo $response;

4) Enjoy!