neznajki/json-rpc-server

server for json rpc

v0.2.1 2020-07-24 10:36 UTC

This package is auto-updated.

Last update: 2024-04-24 19:36:31 UTC


README

makes authorization for json rpc

installation

  • composer require neznajki/json-rpc-server
  • services.yaml
imports:
    - { resource: '@JsonRpcServerBundle/Resources/config/services.yaml' }
  • routes.yaml
jsonRpc:
    resource: '@JsonRpcServerBundle/Resources/config/routing.yaml'

method creation

    App\Api\CoolMethod:
        tags: [ 'json.rpc.server.method' ]
class CoolMethod implements MethodHandlerInterface
{
    /**
     * @param string $test
     * @param int|null $test2
     * @return mixed
     */
    public function handle(string $test = null, ?int $test2 = null)
    {
        return $test . 'tt';
    }

    /**
     * @return string
     */
    public function getMethod(): string
    {
        return 'coolMethodIncomingName';
    }

    /**
     * @return array
     */
    public function getRequiredParameters(): array
    {
        return ['test'];
    }
}