2017 © Pedro Peláez
 

library jsonrpc2

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

image

foglcz/jsonrpc2

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

  • Friday, August 25, 2017
  • by foglcz
  • Repository
  • 3 Watchers
  • 21 Stars
  • 4,502 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 10 Forks
  • 1 Open issues
  • 3 Versions
  • 2 % Grown

The README.md

JSON-RPC client and server libraries

This library contains a PHP implementation of JSON-RPC version 2, both client and server., (*1)

Installation

Download the contents of the lib folder to your project. Then simply include the library:, (*2)

include "lib/Server.php";

Server methods

$server = new Lightbulb\Json\Rpc2\Server;

// Class based where all the methods in myClass are exposed as user.method
$server->user = new MyClass;

// Anything that is "callable", either built in PHP functions or your own
$server->upper     = 'strtoupper';
$server->userClean = 'userClean';

// Anonymous functions work too
$server->firstTwo = function($str) { return substr($str,0,2); };

// Force a namespace to map to an object method
$server->{'mytesthandler.myfunc'} = array($myObject, 'myMethod');

// Static method calls work
$server->myStaticHandler = 'MyStaticClass::theStaticFunction';

The methods, which are given to the server, can be then called via numbered or named parameters (see json-rpc specification here: http://groups.google.com/group/json-rpc/web/json-rpc-2-0?pli=1 ), (*3)

The server class respects binding of event methods:, (*4)

// Bind events
$server->onBeforeCall[] = function($server) {};
$server->onBeforeCall[] = function($server) {};
$server->onSuccess[]    = function($server) {};
$server->onError[]      = function($server) {};

For detailed usage see comments with the server and clients class. For detailed tests see tests folder., (*5)

Client calls

$client = new Lightbulb\Json\Rpc2\Client('http://api.domain.com/endpoint');
$client->upper("kitten");
$client->firstTwo("Hello");

Client supports class chaining to call nested methods

$ok = $client->user->login($user, $pass);

will actually result in following json call:, (*6)

{... method: "user.login" ...}

License

Licensed under the New BSD License. Copyright 2011 Pavel Ptacek. All rights reserved., (*7)

The Versions

25/08 2017

dev-master

9999999-dev http://github.com/foglcz/JSONRpc2

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

  Sources   Download

New BSD

The Requires

  • php >=5.3.2

 

json nette rpc

21/02 2014

v1.1.0

1.1.0.0 http://github.com/foglcz/JSONRpc2

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

  Sources   Download

New BSD

The Requires

  • php >=5.3.2

 

json nette rpc

27/07 2012

v1.0.0

1.0.0.0 http://github.com/foglcz/JSONRpc2

jsonrpc2 implementation for generic use. Test suite for Nette Framework included.

  Sources   Download

New BSD

The Requires

  • php >=5.3.2

 

json nette rpc