PHP code example of royalcms / laravel-jsonrpc-client

1. Go to this page and download the library: Download royalcms/laravel-jsonrpc-client 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/ */

    

royalcms / laravel-jsonrpc-client example snippets


'providers' => [
    // ...
    Royalcms\Laravel\JsonRpcClient\JsonRpcClientServiceProvider::class,
]

return [
    'services' => [
        [
            'services' => [
                'CalculatorService',
                'ProductService',
            ],
            'nodes' => [
                ['host' => '127.0.0.1', 'port' => 9503, 'path' => '/rpc'],
                ['host' => '127.0.0.1', 'port' => 9503, 'path' => '/rpc']
            ]
        ]
    ]
];


use Royalcms\Laravel\JsonRpcClient\JsonRpcHttpClient;

class a extends JsonRpcHttpClient {
    /**
     * The service name of the target service.
     *
     * @var string
     */
    protected $serviceName = 'ProductService';

    /**
     * The protocol of the target service, this protocol name
     *
     * @var string
     */
    protected $protocol = 'jsonrpc-http';


    // 实现一个加法方法,这里简单的认为参数都是 int 类型
    public function list($where,$select,$page,$perPage)
    {
        return $this->__request(__FUNCTION__,compact('where','select','page','perPage'));
    }

}

$a = new a();

$resp = $a->list(" id > 10001 and status > 0 ",['id'],1,10);

$ php artisan vendor:publish