1 Star 0 Fork 5

川流不息 / easyswoole_admin

forked from 李紫电 / easyswoole_admin 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
EasySwooleEvent.php 1.92 KB
一键复制 编辑 原始数据 按行查看 历史
tiandian 提交于 2019-03-31 17:02 . easyswoole简易后台管理系统
<?php
/**
* Created by PhpStorm.
* User: yf
* Date: 2018/5/28
* Time: 下午6:33
*/
namespace EasySwoole\EasySwoole;
use App\Process\Inotify;
use EasySwoole\EasySwoole\Swoole\EventRegister;
use EasySwoole\EasySwoole\AbstractInterface\Event;
use EasySwoole\Http\Request;
use EasySwoole\Http\Response;
use EasySwoole\Utility\File;
use EasySwoole\Component\Pool\PoolManager;
class EasySwooleEvent implements Event
{
public static function initialize()
{
// TODO: Implement initialize() method.
date_default_timezone_set('Asia/Shanghai');
//引用自定义文件配置
self::loadConf();
// 注册mysql数据库连接池
PoolManager::getInstance()->register(MysqlPool::class, Config::getInstance()->getConf('MYSQL.POOL_MAX_NUM'));
}
/**
* 引用自定义配置文件
* @throws \Exception
*/
public static function loadConf()
{
$files = File::scanDirectory(EASYSWOOLE_ROOT . '/App/Config');
if (is_array($files)) {
foreach ($files['files'] as $file) {
$fileNameArr = explode('.', $file);
$fileSuffix = end($fileNameArr);
if ($fileSuffix == 'php') {
Config::getInstance()->loadFile($file);
} elseif ($fileSuffix == 'env') {
Config::getInstance()->loadEnv($file);
}
}
}
}
public static function mainServerCreate(EventRegister $register)
{
// 开启热重启进程
ServerManager::getInstance()->getSwooleServer()->addProcess((new Inotify('autoReload', ['disableInotify' => false]))->getProcess());
}
public static function onRequest(Request $request, Response $response): bool
{
// TODO: Implement onRequest() method.
return true;
}
public static function afterRequest(Request $request, Response $response): void
{
// TODO: Implement afterAction() method.
}
}
PHP
1
https://gitee.com/ygx11/easyswoole_admin.git
git@gitee.com:ygx11/easyswoole_admin.git
ygx11
easyswoole_admin
easyswoole_admin
master

搜索帮助