solution / json-rpc-bundle
Wrapper for Zend2 Json Rpc Server
Installs: 3 064
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 1
Requires
- symfony/framework-bundle: ~2.1
- zendframework/zend-json: 2.4.0
- zendframework/zend-server: 2.4.0
Requires (Dev)
- phpspec/phpspec: dev-develop
- phpspec/prophecy: dev-master
- sensio/framework-extra-bundle: *
- symfony/browser-kit: *
- symfony/class-loader: *
- symfony/security-bundle: *
- symfony/validator: *
- symfony/yaml: *
This package is not auto-updated.
Last update: 2024-11-19 03:01:11 UTC
README
Symfony2 Bundle wrapper to Zend JsonRpc Server
Installation
Add solution/json-rpc-bundle
to composer.json
:
{ "require": { "solution/json-rpc-bundle": "dev-master" } }
Add SolutionJsonRpcBundle
to your AppKernel.php
:
$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:
#app/config/config.yml solution_json_rpc: bundles: [ Bundle1, Bundle2 ]
Add route to your routing.yml
:
mailer_api: resource: @SolutionJsonRpcBundle/Resources/config/routing.yml prefix: /api/json-rpc/
Usage
Class annotation:
use Solution\JsonRpcBundle\Annotation as Api; /** * @Api\JsonRpcApi(service = "api", namespace="test-api") */
Method annotation:
/** * @Api\JsonRpcMethod * * @param null $id * @return bool */ public function getTemplate($id = null) { return [ "id" => 83, "name" => "test" ]; }
Post request example:
{"jsonrpc":"2.0","method":"test-api.getTemplate","params":[4],"id":"foo"}
Response example:
{"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