...
|
...
|
@@ -126,7 +126,6 @@ class SwrpcServerCom extends Command |
|
|
$this->error('SWRPC_SERVER_PORT未设置');
|
|
|
return -1;
|
|
|
}
|
|
|
|
|
|
$logger = new Logger('swrpc');
|
|
|
$logger->pushHandler(new StreamHandler(STDOUT, Logger::INFO));
|
|
|
$server = new Server($name, $host, $port, [
|
...
|
...
|
@@ -140,21 +139,21 @@ class SwrpcServerCom extends Command |
|
|
|
|
|
$filters = [];
|
|
|
$specifyModules = $this->option('module') ? explode(',', $this->option('module')) : [];
|
|
|
$modules = Module::all();
|
|
|
/** @var \Nwidart\Modules\Laravel\Module $module */
|
|
|
foreach ($modules as $module) {
|
|
|
if ($module->getName() == 'Common') {
|
|
|
continue;
|
|
|
}
|
|
|
$loader = require base_path('vendor').'/autoload.php';
|
|
|
// 获取注册的命名空间前缀并筛选出 Composer 包的命名空间
|
|
|
$prefixes = $loader->getPrefixesPsr4();
|
|
|
foreach ($prefixes as $key => $prefix) {
|
|
|
//如果有指定moudle,则只有指定的moudle会生成,否则会生成全部
|
|
|
if (count($specifyModules) > 0 && !in_array($module->getName(), $specifyModules)) {
|
|
|
if (count($specifyModules) > 0 && !in_array($key, $specifyModules, true)) {
|
|
|
continue;
|
|
|
}
|
|
|
$namespace = ltrim(str_replace([base_path(), '/'], ['', '\\'], $module->getPath()), '\\') . '\\Services\\';
|
|
|
$servicePath = $module->getPath() . '/Services';
|
|
|
$namespace = $key . 'Http\Service';
|
|
|
//fetch file
|
|
|
$servicePath = $prefix[0] . '/Http/Service';
|
|
|
if (!is_dir($servicePath)) {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
$queues = scandir($servicePath);
|
|
|
while (count($queues) > 0) {
|
|
|
$file = array_shift($queues);
|
...
|
...
|
@@ -199,7 +198,7 @@ class SwrpcServerCom extends Command |
|
|
*/
|
|
|
protected function build($namespace, $class): ?object
|
|
|
{
|
|
|
$serviceClass = str_replace('/', '\\', $namespace . $class);
|
|
|
$serviceClass = str_replace('/', '\\', $namespace . '\\' . $class);
|
|
|
if (!class_exists($serviceClass)) {
|
|
|
$this->error($serviceClass . '类不存在');
|
|
|
return null;
|
...
|
...
|
|