Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Tree: c74f164184
Fetching contributors…

Cannot retrieve contributors at this time

83 lines (64 sloc) 2.069 kB


json-rpc2php ?

json-rpc2php is a php and javascript library. contains a php json-rpc version 2.0 server and a javascript json-rpc version 2.0 client

Open Source

json-rpc2php is open source under GPLv2 licence. Please consider a donation so I can keep working on this.

Features php server

  • simple registration of php classes

  • simple use

  • catches exceptions and translates them in json-rcp version 2.0 errors

  • supports rpc.listMethods : array of class => methods

Features javascript client library

  • simple configuration (only needs an endpoint)

  • automatic creation of javascript objects for each method available (using the rpc.listMethods)

  • uses the jQuery library

Features PHP Client NEW

  • Simple usage: Directly call object function from client class

Example server

  • api.php

    $myClass = new myClass();
    $jsonRpc = new jsonRPCServer();
    $jsonRpc->handle() or die('no request');
  • my.class.php

    class myClass {
        public function ping($msg) {
            return "pong:" . $msg;

Example javascript client

<script type="javascript/text" src="jsonrpc2php.client.js"></script>
var rpc = new jsonrpcphp('api.php',function(){"hello world!",function(jsonRpcObj){

Example PHP client

 require_once 'jsonRPC2Client.php';
 $myClass = new jsonRPCClient('','myClass');
 print_r($myClass->ping('testing one 2 three.'));
 /* Outputs:
    Array (
        [0] => "pong:testing one 2 three"
Jump to Line
Something went wrong with that request. Please try again.