PHPackages                             moaction/jsonrpc-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. moaction/jsonrpc-bundle

ActiveLibrary[API Development](/categories/api)

moaction/jsonrpc-bundle
=======================

Jsonrpc server and client Symfony2 bundle

v1.1(12y ago)01611MITPHPPHP &gt;=5.3.3

Since Dec 20Pushed 12y ago1 watchersCompare

[ Source](https://github.com/moaction/jsonrpc-bundle)[ Packagist](https://packagist.org/packages/moaction/jsonrpc-bundle)[ RSS](/packages/moaction-jsonrpc-bundle/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

Jsonrpc-bundle
==============

[](#jsonrpc-bundle)

Symfony2 bundle with JSON-Rpc 2.0 protocol implementation

Usage
-----

[](#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
--------------

[](#server-example)

### Controller

[](#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

[](#routing)

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

### Request example

[](#request-example)

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