2017 © Pedro Peláez
 

library json-rpc-bundle

Wrapper for Zend2 Json Rpc Server

image

solution/json-rpc-bundle

Wrapper for Zend2 Json Rpc Server

  • Tuesday, June 2, 2015
  • by f1nder
  • Repository
  • 2 Watchers
  • 0 Stars
  • 2,624 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 1 Versions
  • 9 % Grown

The README.md

SolutionJsonRpcBundle

Symfony2 Bundle wrapper to [Zend JsonRpc Server][1], (*1)

Installation

Add solution/json-rpc-bundle to composer.json:, (*2)

{
   "require": {
        "solution/json-rpc-bundle": "dev-master"
    }
}

Add SolutionJsonRpcBundle to your AppKernel.php:, (*3)

    $bundles = array(
        ...
        new Solution\JsonRpcBundle\SolutionJsonRpcBundle($this),
    );
}

Configuration

Select bundles you want use json-rpc via annotations so that the bundle will pick them up, and add them to your dependency injection container:, (*4)

#app/config/config.yml
solution_json_rpc:
    bundles: [ Bundle1, Bundle2 ]

Add route to your routing.yml:, (*5)

mailer_api:
    resource: @SolutionJsonRpcBundle/Resources/config/routing.yml
    prefix: /api/json-rpc/

Usage

Class annotation:, (*6)

use Solution\JsonRpcBundle\Annotation as Api;
/**
 * @Api\JsonRpcApi(service = "api", namespace="test-api")
 */

Method annotation:, (*7)

    /**
     * @Api\JsonRpcMethod
     *
     * @param null $id
     * @return bool
     */
    public function getTemplate($id = null)
    {
        return [
            "id" => 83,
            "name" => "test"
        ];
    }

Post request example:, (*8)

{"jsonrpc":"2.0","method":"test-api.getTemplate","params":[4],"id":"foo"}

Response example:, (*9)

{"result":[{"id":83,"name":"test"}],"id":"foo","jsonrpc":"2.0"}

@todo - README - Add the ability to describe methods with auto gen SDM - write functional test, (*10)

The Versions