Looking to hire Laravel developers? Try LaraJobs

laravel-jsonrpc maintained by huangdijia

Description
jsonrpc for laravel
Author
Last update
2022/08/24 13:09 (3.x-dev)
License
Downloads
2 865
Tags

Comments
comments powered by Disqus

laravel-jsonrpc

Latest Version on Packagist Total Downloads GitHub license

Installation

composer require huangdijia/laravel-jsonrpc

Usage

As Server

Controller

use Huangdijia\JsonRpc\Traits\JsonRpcServer;

class ExampleController extends Controller
{
    use JsonRpcServer;

    public function action()
    {
        return 'hello, json-rpc';
    }
}

Route

Route::middleware([Huangdijia\JsonRpc\Middleware\JsonRpcMiddleware::class])->group(function() {
    Route::post('/example', ExampleController::class);
});

As Client

$client = new Huangdijia\JsonRpc\Client($url);
$result = $client->action(); // hello, json-rpc