Code Monkey home page Code Monkey logo

jsonrpc's Introduction

Json-Rpc

Build Status

A PHP implementation for JSON-RPC (v2). Contains client and server libraries to handle requests including notification and batch.

Contents

About

JSON-RPC is a protocol that allows servers to talk to each other using json-encoded structures. It is described in its specification as:

A light weight remote procedure call protocol. It is designed to be simple!

Full details at jsonrpc.org. You may need to read this to get an overview of the json structures that are used, although the heavy lifting is abstracted away by this implementation. For example, calling a method on a remote server is as simple as:

<?php
$client = new JsonRpc\Client($url);
$client->call('method', array($param1, $param2));

// now do something with $client->result

And at the server end:

<?php
// MethodsClass contains the exposed methods
$methods = new MethodsClass();

$server = new JsonRpc\Server($methods);
$server->receive();

Installation

The easiest way is through composer. Just create a composer.json file and run php composer.phar install to install it:

{
    "minimum-stability": "dev",
    "require": {
        "jsonrpc/jsonrpc": "1.0.*"
    }
}

Alternatively, you can download and extract it, or clone this repo. If you just want to try it, see Example.

Usage

If you downloaded the library through composer then you must add the following somewhere in your bootstrap code:

<?php
 require 'vendor/autoload.php';

Otherwise you must point a PSR-0 autoloader to the src directory. Full usage documentation can be found in the Wiki:

Example

The quickest way to get the library up and running locally is to point your browser to example/client.php and everything will load automatically. You can then experiment with the code as you read the documentation.

License

Json-Rpc is licensed under the MIT License - see the LICENSE file for details

jsonrpc's People

Contributors

johnstevenson avatar korotin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.