dev-master
9999999-devSimple JsonRpc server for symfony
MIT
The Requires
- php >=5.5
- zendframework/zend-json-server 3.0.0
by Slava Basko
symfony json-rpc
Wallogit.com
2017 © Pedro Peláez
Simple JsonRpc server for symfony
Install via composer and add to kernel., (*1)
class AppKernel extends Kernel
{
public function registerBundles()
{
$bundles = [
...
new JsonRpcServerBundle\JsonRpcBundle(),
];
return $bundles;
}
...
Add this to your routing.yml (or xlm, etc.)., (*2)
json_rpc_server:
path: /api
defaults: { _controller: JsonRpcBundle:Server:process }
Done!, (*3)
Just mark your service with "rpc.service" tag., (*4)
rpc_ping:
class: RpcService\PaymentService
tags:
- { name: rpc.service }
You can use server as a service. Example:, (*5)
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
* @param Request $request
* @return JsonResponse
*/
public function indexAction(Request $request)
{
// Some Logic. Auth, pre-actions, etc.
$rpcServer = $this->get('rpc_server');
if ($request->isMethod('get')) {
return new JsonResponse($rpcServer->getServiceMap()->toArray());
}
return new JsonResponse($rpcServer->handle()->toJson(), 200, [], true);
}
}
Simple JsonRpc server for symfony
MIT
symfony json-rpc