1. Go to this page and download the library: Download luojixinhao/rpc 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/ */
luojixinhao / rpc example snippets
/*服务端*/
class API {
public function api1($arg1 = '', $arg2 = '') {
return "API1返回数据: 参数1={$arg1},参数2={$arg2}";
}
public function api2($arg1 = '', $arg2 = '') {
return array('API2返回数据', $arg1, $arg2);
}
protected function api3() {
return '这个不可调用,返回“ERROR”';
}
}
$service = new rpcServer(new API());
$service->handle();