2017 © Pedro Peláez
 

library json-rpc-lib

JSON-RPC Server/Client for PHP 5.3

image

json-rpc-lib/json-rpc-lib

JSON-RPC Server/Client for PHP 5.3

  • Thursday, July 4, 2013
  • by marcinsoja
  • Repository
  • 2 Watchers
  • 3 Stars
  • 554 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

PHP JSON-RPC Lib

Build Status

Build Status, (*1)

Version

The current version is considered Beta. This means that it is ready enough to test and use, but beware that you should update frequently., (*2)

As this software is BETA, Use at your own risk!, (*3)

About

JSON-RPC Server/Client for PHP 5.3, (*4)

Installation

PHAR

Download the latest phar build. Then, just require the phar in your code!, (*5)

require_once '/path/to/JsonRpcLib.phar';, (*6)

Composer

Add a composer.json file to your project with the following:, (*7)

{
    "require": {
        "json-rpc-lib/json-rpc-lib": "dev-master"
    }
}

Then, inside that folder, just run php composer.phar install., (*8)

Then, in your code, just use the composer autoloader:, (*9)

require_once 'vendor/autoload.php';, (*10)

That's it!, (*11)

Usage - Server

Most use-cases can simply use the root JsonRpcLib\Server\Server class., (*12)

<?php

require_once 'vendor/autoload.php';

$server = new \JsonRpcLib\Server\Server();

$server->addService($service);

$server->handle();

Service Closure

<?php

require_once 'vendor/autoload.php';

$server = new \JsonRpcLib\Server\Server();

$server->addService(function($a, $b) {
    return $a + $b;
}, 'sum'); // sum

$server->handle();

Service Object

<?php

require_once 'vendor/autoload.php';

class MockService {
    public function sum($a, $b) {
        return $a + $b;
    }
}

$service = new MockService();

$server = new \JsonRpcLib\Server\Server();
$server->addService($service); // sum
$server->handle();

or, (*13)

<?php

// ...

$server->addService($service, 'math'); // math.sum

// ...

Multiple services

<?php

// ...

$server->addService($service, 'math'); // math.sum

$server->addService(function($data){
    // update data
}, 'update'); // update

$server->addService(function($a, $b){
    return $a + $b;
}, 'sum'); // sum

$server->addService($userService, 'user'); // user.getName, user.getSurname, user.*

// ...

Full configuration

<?php

$in = new JsonRpcLib\Server\Input\Data\Input();
$out = new JsonRpcLib\Server\Output\Data\Output();

$inputMessage = new JsonRpcLib\Server\Input\Message($in);
$outputMessage = new JsonRpcLib\Server\Output\Message($out);

$resolver = new \JsonRpcLib\Server\Service\Resolver\Resolver();

$manager = new JsonRpcLib\Server\Service\Manager\Manager($resolver);

$server = new JsonRpcLib\Server\Server($manager);

$server->addService(new \JsonRpcLib\Server\Service\Wrapper\ClosureWrapper($closure), 'getYear');
$server->addService(new \JsonRpcLib\Server\Service\Wrapper\ObjectWrapper($object), 'getName');

$server->dispatch($inputMessage, $outputMessage);

Design Goals

Well Designed

The code will use industry standard design patterns as well as follow guidelines for clean and testable code., (*14)

Well Tested

That means that the code should be well covered by unit tests., (*15)

Easy To Install

PHP JsonRpcLib will support two install methods. The first method is a single file PHAR archive. The second is support via Composer., (*16)

Easy To Extend

The library should be very easy to extend and add new functionality., (*17)

The Versions

04/07 2013

dev-feature-client

dev-feature-client https://github.com/marcinsoja/php-json-rpc

JSON-RPC Server/Client for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

json server client json-rpc rpc

30/06 2013

dev-develop

dev-develop https://github.com/marcinsoja/php-json-rpc

JSON-RPC Server/Client for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

json server client json-rpc rpc

30/06 2013

dev-master

9999999-dev https://github.com/marcinsoja/php-json-rpc

JSON-RPC Server/Client for PHP 5.3

  Sources   Download

MIT

The Requires

  • php >=5.3.0

 

The Development Requires

json server client json-rpc rpc