JSON-RPC 2.0 Server for Symfony
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require neofusion/json-rpc-bundleThis command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Then, enable the bundle by adding it to the list of registered bundles
in the app/AppKernel.php file of your project:
<?php
// app/AppKernel.php
// ...
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = array(
// ...
new NeoFusion\JsonRpcBundle\NeoFusionJsonRpcBundle(),
);
// ...
}
// ...
}You can easily define methods in your configuration file:
neofusion_jsonrpc:
routing:
customer:
path: /customer
methods:
comment.create: { service: 'app.api.customer.comment', action: 'create' }
comment.delete: { service: 'app.api.customer.comment', action: 'delete' }routing- list of routescustomer- internal name of a routepath- second part of URL after prefixmethods- list of methodscomment.create- method nameservice- name of a service, which contains callable methodsaction- callable method from the service
Finally, register this bundle's routes by adding the following to your project's routing file:
# app/config/routing.yml
neofusion_jsonrpc:
resource: "@NeoFusionJsonRpcBundle/Resources/config/routing.yml"
prefix: /api
