2017 © Pedro Peláez
 

library jsonrpc-bundle

Jsonrpc server and client Symfony2 bundle

image

moaction/jsonrpc-bundle

Jsonrpc server and client Symfony2 bundle

  • Friday, December 20, 2013
  • by nitso
  • Repository
  • 1 Watchers
  • 0 Stars
  • 48 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 0 % Grown

The README.md

Jsonrpc-bundle

Symfony2 bundle with JSON-Rpc 2.0 protocol implementation, (*1)

http://www.jsonrpc.org/specification, (*2)

Usage

  1. Create a controller that extends \Moaction\JsonrpcBundle\Controller\JsonrpcController
  2. Add routing for 'execute' method
  3. Add some public methods with 'Method' postfix
  4. Enjoy the magic!

Server Example

Controller

class ApiController extends \Moaction\JsonrpcBundle\Controller\JsonrpcController {
  public function getUserMethod($id) {
    return 'User id is ' . $id;
  }

  public function getUserPostMethod($userId, $postId) {
    return array(
     'userId' => $userId,
     'postId' => $postId
    );
  }
}

Routing

AcmeBundle_jsonrpc_api:
    pattern:  /api
    defaults: { _controller: AcmeBundle:Api:execute }

Request example

--> {"jsonrpc": "2.0", "method": "getUser", "params": {"id": 23}, "id": 1}
<-- {"jsonrpc": "2.0", "id": 1, "result": "User id is 23"}
--> {"jsonrpc": "2.0", "method": "getUserPost", "params": {"userId": 23, "postId": 456}, "id": 2}
<-- {"jsonrpc": "2.0", "id": 2, "result": {"userId": 23, "postId": 456}}

Client example

For usage take a look at moaction/jsonrpc-client examples., (*3)

Client class exists in parameter moaction_jsonrpc.client.class, (*4)

You can add dependency to any service using client class parameter. Don't forget to add url argument for service:, (*5)

services.yml:, (*6)

services:
    acme_hello.api.client:
        class: %moaction_jsonrpc.client.class%
        arguments:
            - "http://example.com/api/jsonrpc"

The Versions

20/12 2013

dev-master

9999999-dev

Jsonrpc server and client Symfony2 bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin

20/12 2013

v1.1

1.1.0.0

Jsonrpc server and client Symfony2 bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin

20/12 2013

v1.0

1.0.0.0

Jsonrpc server and client Symfony2 bundle

  Sources   Download

MIT

The Requires

 

The Development Requires

by Alexey Kalinin