PHP code example of huangdijia / laravel-jsonrpc

1. Go to this page and download the library: Download huangdijia/laravel-jsonrpc library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

huangdijia / laravel-jsonrpc example snippets


use Huangdijia\JsonRpc\Traits\JsonRpcServer;

class ExampleController extends Controller
{
    use JsonRpcServer;

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

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

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