2017 © Pedro Peláez
 

library symphony-json-rpc-server

Simple JsonRpc server for symfony

image

slava-basko/symphony-json-rpc-server

Simple JsonRpc server for symfony

  • Thursday, February 2, 2017
  • by slava-basko
  • Repository
  • 1 Watchers
  • 0 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Simple JsonRpc Server for Symfony

Install

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)

Usage

Just mark your service with "rpc.service" tag., (*4)

rpc_ping:
    class: RpcService\PaymentService
    tags:
        - { name: rpc.service }

Advanced Configuration

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);
    }
}

The Versions

02/02 2017

dev-master

9999999-dev

Simple JsonRpc server for symfony

  Sources   Download

MIT

The Requires

 

by Slava Basko

symfony json-rpc