1. Go to this page and download the library: Download xcl3721/dora-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/ */
class Server extends DoraRPCServer {
//all of this config for optimize performance
//以下配置为优化服务性能用,请实际压测调试
protected $externalConfig = array(
//to improve the accept performance ,suggest the number of cpu X 2
//如果想提高请求接收能力,更改这个,推荐cpu个数x2
'reactor_num' => 32,
//packet decode process,change by condition
//包处理进程,根据情况调整数量
'worker_num' => 40,
//the number of task logical process progcessor run you business code
//实际业务处理进程,根据需要进行调整
'task_worker_num' => 20,
);
function initServer($server){
//the callback of the server init 附加服务初始化
//such as swoole atomic table or buffer 可以放置swoole的计数器,table等
}
function doWork($param){
//process you logical 业务实际处理代码仍这里
//return the result 使用return返回处理结果
return array("hehe"=>"ohyes");
}
function initTask($server, $worker_id){
//
//redis for service discovery register
//when you on product env please prepare more redis to registe service for high available
$redisconfig = array(
array(//first reporter
"ip" => "127.0.0.1",
"port" => "6379",
),
array(//next reporter
"ip" => "127.0.0.1",
"port" => "6379",
),
);
//ok start server
$res = new \DoraRPC\Monitor("0.0.0.0", 9569, $redisconfig, "./client.conf.php");
//this server will auto get the node server list from redis and general the client config on special path
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.