add composer module support (build 449, 2.7.2)

This commit is contained in:
crazywhalecc
2022-03-21 01:24:07 +08:00
parent c5a6f1fea4
commit b3089c1bba
5 changed files with 96 additions and 5 deletions

View File

@@ -165,9 +165,6 @@ class OnWorkerStart implements SwooleEvent
if (trim($k, '\\') == 'ZM') {
continue;
}
if (\server()->worker_id == 0) {
Console::verbose('Add ' . $v . ":{$k} to register path");
}
$parser->addRegisterPath(DataProvider::getSourceRootDir() . '/' . $v . '/', trim($k, '\\'));
}
}
@@ -187,6 +184,15 @@ class OnWorkerStart implements SwooleEvent
}
}
// 检查所有的Composer模块并加载注解
$list = ModuleManager::getComposerModules();
foreach ($list as $k => $v) {
if (\server()->worker_id === 0) {
Console::info('Loading composer module: ' . $k);
}
$parser->addRegisterPath($v['module-path'], $v['namespace']);
}
$parser->registerMods();
EventManager::loadEventByParser($parser); // 加载事件