require_once __DIR__.'/vendor/autoload.php';
$http = new \HttpServer\HttpServer("http://0.0.0.0:21001");
//进程名字
$http->name = 'HttpServer';
//进程数量
$http->count = 4;
//配置文件地址
$http->config_file = __DIR__.'/config.php';
\Workerman\Worker::runAll();
return [
'domain' => [
'localhost' => [ //域名
'root' => __DIR__, //start.php启动文件的目录的绝对路径
'controller' => '/backend/controllers', //项目文件根目录
'statics' => '/backend/web', //静态资源根目录
]
],
'db' => [
'HttpServer' => [
'host' => '127.0.0.1',
'port' => 3306,
'user' => 'root',
'password' => '123456',
'dbname' => 'HttpServer',
'charset' => 'utf8mb4',
],
],
'redis' => [
'HttpServer' => [
'host' => '127.0.0.1',
'port' => '6379',
'password' => '123456',
'db' => 1
]
]
];
namespace backend\controllers;
use HttpServer\Controllers;
class Index extends Controllers
{
public function index(){
$this->send('Hello Roc');
}
public function hello(){
$this->sendJson(['msg'=>'Hello World!!!']);
}
}