esd / base-server
base-server
0.64
2019-05-23 09:17 UTC
Requires
- doctrine/annotations: ^1.6
- monolog/monolog: ^1.24
- ocramius/proxy-manager: ^2.1
- php-di/php-di: ^6.0
- symfony/console: ^4.2
- symfony/yaml: ^4.2
- dev-master
- 0.64
- 0.63
- 0.62
- 0.61
- 0.60
- 0.59
- 0.58
- 0.57
- 0.56
- 0.55
- 0.54
- 0.53
- 0.52
- 0.51
- 0.50
- 0.49
- 0.48
- 0.47
- 0.46
- 0.45
- 0.44
- 0.43
- 0.42
- 0.41
- 0.40
- 0.39
- 0.38
- 0.37
- 0.36
- 0.35
- 0.34
- 0.33
- 0.32
- 0.31
- 0.30
- 0.29
- 0.28
- 0.27
- 0.26
- 0.25
- 0.24
- 0.23
- 0.22
- 0.21
- 0.20
- 0.19
- 0.18
- 0.17
- 0.16
- 0.15
- 0.14
- 0.13
- 0.12
- 0.11
- 0.10
- 0.9
- 0.8
- 0.7
- 0.6
- 0.5
- 0.4
- 0.3
- 0.2
- 0.1
- 0.0.1
- dev-change
This package is auto-updated.
Last update: 2024-10-25 07:20:58 UTC
README
基础服务
封装swoole,模块更科学更易用
class MyPort extends DefaultServerPort
{
}
class MyProcess extends DefaultProcess
{
}
enableRuntimeCoroutine();
//----多端口配置----
$httpPortConfig = new PortConfig();
$httpPortConfig->setHost("0.0.0.0");
$httpPortConfig->setPort(8080);
$httpPortConfig->setSockType(PortConfig::SWOOLE_SOCK_TCP);
$httpPortConfig->setOpenHttpProtocol(true);
$wsPortConfig = new PortConfig();
$wsPortConfig->setHost("0.0.0.0");
$wsPortConfig->setPort(8081);
$wsPortConfig->setSockType(PortConfig::SWOOLE_SOCK_TCP);
$wsPortConfig->setOpenHttpProtocol(true);
//---服务器配置---
$serverConfig = new ServerConfig();
$serverConfig->setWorkerNum(4);
$serverConfig->setLogFile(__DIR__ . "/../swoole.log");
$serverConfig->setPidFile(__DIR__ . "/../pid");
$server = new DefaultServer($serverConfig);
try {
//添加端口
$httpPort = $server->addPort($httpPortConfig, MyPort::class);//使用自定义实例
$wsPort = $server->addPort($wsPortConfig);//使用默认实例
//添加进程
$test1Process = $server->addProcess("test1");
$test2Process = $server->addProcess("test2", MyProcess::class);//使用自定义实例
//配置
$server->configure();
//启动
$server->start();
} catch (Exception $e) {
var_dump($e->getTrace());
}