With composer
composer require thiagof/laravelrpc
Laravel configuration
php artisan config:publish thiagof/laravelrpc
# Laravel > 5.1
php artisan vendor:publish --provider="Thiagof\LaravelRPC\RpcServiceProvider"
Include the provider in app/config/app.php
:
'providers' => array(
[...]
'Thiagof\LaravelRPC\RpcServiceProvider',
);
Also include the alias
'providers' => array(
[...]
'Thiagof\LaravelRPC\RpcClientFacade',
'Thiagof\LaravelRPC\RpcServerFacade',
);
Setup your Client/Server properties in your app config/rpc.php
The Client
<?php
use RpcClient;
$result = RpcClient::myServerMethod();
The Server
<?php
Route::post('rpc', function() {
$server = app('JsonRpcServer');
$server->attach(new MyRpcMethods);
$server->execute();
});
Please refer to fguillot/json-rpc