2017 © Pedro Peláez
 

library guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

image

graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  • Tuesday, January 2, 2018
  • by graze
  • Repository
  • 14 Watchers
  • 57 Stars
  • 176,943 Installations
  • PHP
  • 17 Dependents
  • 0 Suggesters
  • 15 Forks
  • 3 Open issues
  • 29 Versions
  • 8 % Grown

The README.md

[ABANDONED] Guzzle JSON-RPC

No Maintenance Intended, (*1)

This is no longer supported, please consider forking this repository to make any desired changes.

![Master branch build status][ico-build] ![Coverage Status][ico-coverage] Quality Score Published version PHP ~5.5 ![MIT Licensed][ico-license], (*2)

This library implements JSON-RPC 2.0 for the Guzzle HTTP client. We try to support all commonly used versions of Guzzle including:, (*3)

It can be installed in whichever way you prefer, but we recommend Composer., (*4)

{
    "require": {
        "graze/guzzle-jsonrpc": "~3.0"
    }
}

Documentation

<?php
use Graze\GuzzleHttp\JsonRpc\Client;

// Create the client
$client = Client::factory('http://localhost:8000');

// Send a notification
$client->send($client->notification('method', ['key'=>'value']));

// Send a request that expects a response
$client->send($client->request(123, 'method', ['key'=>'value']));

// Send a batch of requests
$client->sendAll([
    $client->request(123, 'method', ['key'=>'value']),
    $client->request(456, 'method', ['key'=>'value']),
    $client->notification('method', ['key'=>'value'])
]);

Async requests

Asynchronous requests are supported by making use of the Guzzle Promises library; an implementation of Promises/A+., (*5)

<?php
use Graze\GuzzleHttp\JsonRpc\Client;

// Create the client
$client = Client::factory('http://localhost:8000');

// Send an async notification
$promise = $client->sendAsync($client->notification('method', ['key'=>'value']));
$promise->then(function () {
    // Do something
});

// Send an async request that expects a response
$promise = $client->sendAsync($client->request(123, 'method', ['key'=>'value']));
$promise->then(function ($response) {
    // Do something with the response
});

// Send a batch of requests
$client->sendAllAsync([
    $client->request(123, 'method', ['key'=>'value']),
    $client->request(456, 'method', ['key'=>'value']),
    $client->notification('method', ['key'=>'value'])
])->then(function ($responses) {
    // Do something with the list of responses
});

Throw exception on RPC error

You can throw an exception if you receive an RPC error response by adding the option [rpc_error => true] in the client constructor., (*6)

<?php
use Graze\GuzzleHttp\JsonRpc\Client;
use Graze\GuzzleHttp\JsonRpc\Exception\RequestException;

// Create the client with the `rpc_error`
$client = Client::factory('http://localhost:8000', ['rpc_error'=>true]);

// Create a request
$request = $client->request(123, 'method', ['key'=>'value']);

// Send the request
try {
    $client->send($request);
} catch (RequestException $e) {
    die($e->getResponse()->getRpcErrorMessage());
}

Contributing

We accept contributions to the source via Pull Request, but passing unit tests must be included before it will be considered for merge., (*7)

~ $ make deps
~ $ make lint test

License

The content of this library is released under the MIT License by Nature Delivered Ltd., (*8)

You can find a copy of this license at mit or in LICENSE, (*9)

The Versions

02/01 2018

dev-guzzle-5

dev-guzzle-5 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

02/01 2018

2.1.1

2.1.1.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

13/12 2017

dev-g-5-subscribers-factory

dev-g-5-subscribers-factory https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

21/09 2017
15/09 2017

dev-composer-platform

dev-composer-platform https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

22/08 2017

dev-docker-g-5

dev-docker-g-5 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

22/08 2017

dev-docker-g-3

dev-docker-g-3 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc

22/08 2017

dev-docker-g-4

dev-docker-g-4 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp

16/02 2016
07/01 2016
01/12 2015

dev-docs-patch

dev-docs-patch https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

15/09 2015
14/09 2015

3.0.0

3.0.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

30/10 2014

2.1.0

2.1.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp ring

30/10 2014

dev-guzzle-4

dev-guzzle-4 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp

06/10 2014

2.0.1

2.0.1.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp

06/10 2014

2.0.0

2.0.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc guzzlehttp

24/09 2014

dev-guzzle-3

dev-guzzle-3 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc

24/09 2014

1.0.0

1.0.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc

17/06 2014

0.4.3

0.4.3.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc

11/06 2014

0.4.1

0.4.1.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc

08/04 2014

0.4.0

0.4.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC 2.0 client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle json-rpc jsonrpc rpc

18/03 2014

0.3.0

0.3.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc

05/02 2014

0.2.3

0.2.3.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc

31/01 2014

0.2.2

0.2.2.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc

13/01 2014

0.2.1

0.2.1.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc

10/01 2014

0.2.0

0.2.0.0 https://github.com/graze/guzzle-jsonrpc

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc

26/06 2013

0.1.1

0.1.1.0 https://github.com/graze/event

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc

26/06 2013

0.1.0

0.1.0.0 https://github.com/graze/event

JSON-RPC client for Guzzle

  Sources   Download

MIT

The Requires

 

The Development Requires

json http guzzle jsonrpc rpc