nizsheanez/yii2-json-rpc

A lightweight JsonRpc Server and Client for PHP

Installs: 8 562

Dependents: 0

Suggesters: 0

Security: 0

Stars: 19

Watchers: 3

Forks: 21

Open Issues: 1

Type:yii2-extension

v1.1.8 2018-06-12 05:27 UTC

This package is not auto-updated.

Last update: 2020-09-17 12:08:38 UTC


README

JsonRpc Server and Client for Yii2

##Usage Server

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

php composer.phar update
  1. Add action to controller
public function actions()
{
    return array(
        'index' => array(
            'class' => \nizsheanez\jsonRpc\Action::class,
        ),
    );
}

public function sum($a, $b) {
	return $a + $b;
}
  1. 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;
  1. Enjoy!