2017 © Pedro Peláez
 

library jsonrpc-common

Jsonrpc common libraries

image

moaction/jsonrpc-common

Jsonrpc common libraries

  • Wednesday, December 18, 2013
  • by nitso
  • Repository
  • 1 Watchers
  • 0 Stars
  • 122 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

Jsonrpc-common

Common libraries for JSON-Rpc 2.0 protocol implementation, (*1)

http://www.jsonrpc.org/specification, (*2)

Libraries are used in jsonrpc-client and jsonrpc-server, (*3)

Request

class \Moaction\Jsonrpc\Common\Request, (*4)

Fields (getters and setters for fields):

  • method
  • id
  • params

Methods

  • toArray()
$request = new \Moaction\Jsonrpc\Common\Request
$request->setId(1);
$request->setMethod('getUserData');
$request->setParams(array('userId' => 4, 'field' => 'email'));
// here you get valid jsonrpc 2.0 request object ready for json_encode
// \InvalidArgumentException can be thrown when Request object is misconfigured (method is not set).
$data = $request->toArray();

Response

class \Moaction\Jsonrpc\Common\Response, (*5)

Fields (getters and setters for fields):

  • result
  • error
  • id

Methods

  • fromArray()
  • hasError()

Normal response

// decoded array with jsonrpc 2.0 response
$data = array(
    'id'     => 1,
    'result' => array(
        'email' => 'user@example.com',
    ),
);
// \Moaction\Jsonrpc\Common\Exception can be thrown when object is not valid jsonrpc response
$response = new \Moaction\Jsonrpc\Common\Response::fromArray($data);

Error response

// decoded array with jsonrpc 2.0 response
$data = array(
    'id'     => 1,
    'error' => array(
        'code' => '20',
        'message' => 'User not found',
        'data' => array('userId' => 4),
    ),
);
$response = new \Moaction\Jsonrpc\Common\Response::fromArray($data);
// \Moaction\Jsonrpc\Common\Error object
$error = $response->getError();

Error

class \Moaction\Jsonrpc\Common\Error, (*6)

Error object. See response for example., (*7)

Exception

class \Moaction\Jsonrpc\Common\Exception, (*8)

Exception for using in jsonrpc libraries, (*9)

The Versions

18/12 2013

dev-master

9999999-dev

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin

18/12 2013

v1.5

1.5.0.0

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin

10/12 2013

v1.4

1.4.0.0

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin

10/12 2013

v1.3

1.3.0.0

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin

09/12 2013

v1.2

1.2.0.0

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin

06/12 2013

v1.1

1.1.0.0

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin

04/12 2013

v1.0

1.0.0.0

Jsonrpc common libraries

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

by Alexey Kalinin