Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/raoptimus/yii2-jsonrpc2

Json RPC client 1.0 and 2.0 versions for Yii2
https://github.com/raoptimus/yii2-jsonrpc2

json-rpc-client json-rpc2-client jsonrpc jsonrpc2 php yii2 yii2-extension yii2-jsonrpc yii2-jsonrpc2

Last synced: 2 months ago
JSON representation

Json RPC client 1.0 and 2.0 versions for Yii2

Awesome Lists containing this project

README

        

[![Stable Version](https://poser.pugx.org/raoptimus/yii2-jsonrpc2/v/stable)](https://packagist.org/packages/raoptimus/yii2-jsonrpc2)
[![Untable Version](https://poser.pugx.org/raoptimus/yii2-jsonrpc2/v/unstable)](https://packagist.org/packages/raoptimus/yii2-jsonrpc2)
[![License](https://poser.pugx.org/raoptimus/yii2-jsonrpc2/license)](https://packagist.org/packages/raoptimus/yii2-jsonrpc2)
[![Total Downloads](https://poser.pugx.org/raoptimus/yii2-jsonrpc2/downloads)](https://packagist.org/packages/raoptimus/yii2-jsonrpc2)
[![Build Status](https://travis-ci.com/raoptimus/yii2-jsonrpc2.svg?branch=master)](https://travis-ci.com/raoptimus/yii2-jsonrpc2)

# yii2-jsonrpc2
Json RPC client 1.0 and 2.0 versions for Yii2

## Installation

Install with composer:

```bash
composer require raoptimus/yii2-jsonrpc2
```

## Usage samples

Configuration

```php
return [
//....
'components' =>
'jsonrpc' => [
'class' => raoptimus\jsonrpc2\Connection::class,
'hostname' => 'localhost',
'port' => 8666,
],
];
```

```php
return [
//....
'components' =>
'jsonrpc' => [
'class' => raoptimus\jsonrpc2\Connection::class,
'unixSocket' => '/tmp/jsonrpc2.sock',
'spec' => raoptimus\jsonrpc2\Connection::SPEC_2_0,
],
];
```

Use connection

```php
$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);
```