angernaughts / jsonrpc
JSON RPC 2.0 Server for Laravel 5.4+
This package's canonical repository appears to be gone and the package has been frozen as a result.
dev-master / 1.0.x-dev
2018-04-19 12:11 UTC
Requires
- php: >=7.1.0
- illuminate/http: >=5.4
- illuminate/support: >=5.4
This package is not auto-updated.
Last update: 2021-02-20 09:36:08 UTC
README
JSON RPC 2.0 Server for Laravel 5.4+
installation:
$ composer require angernaughts/jsonrpc
usage:
Route::group(['prefix' => 'v1'], function () { Route::post('/jsonrpc', function (JsonRpcServer $server) { $test = new \App\Test(); $server->getRequestProcessor() ->withClass(\App\Test::class, 'withClass.') ->withClass($test, 'withClassInstance.') ->withClassMethod('withClassInstanceMethod', \App\Test::class, 'publicTest') ->withClassMethod('withClassInstanceMethod', $test, 'publicTest') ->withClassMethod('publicTest', $test) ->withCallback('withCallback', function (string $foo, int $bar) { return [ 'foo' => $foo, 'bar' => $bar, ]; }) ->withProcedureTree('app', [ 'environment', 'version', 'locale' => 'getLocale', ], app()) ->withProcedureTree('test', [ 'methods' => [ 'class' => \App\Test::class, 'procedures' => [ 'allMethods' => \App\Test::class, 'oneMethod' => 'publicTest', 'publicTest', 'staticTest', 'byClassMethod' => [\App\Test::class, 'publicTest'], 'byInstanceMethod' => [$test, 'publicTest'], ], ], 'callback' => function () { return 'callback'; }, 'publicTest', ], $test); return $server->run(); }); });