mirror of
https://github.com/zhamao-robot/zhamao-framework.git
synced 2026-07-23 16:45:35 +08:00
fix command loader relative path
This commit is contained in:
@@ -9,7 +9,6 @@ use Symfony\Component\Console\Input\InputOption;
|
|||||||
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
use Symfony\Component\Console\Output\ConsoleSectionOutput;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
use ZM\Exception\InitException;
|
use ZM\Exception\InitException;
|
||||||
use ZM\Utils\ZMUtil;
|
|
||||||
|
|
||||||
#[AsCommand(name: 'init', description: '初始化框架运行的基础文件')]
|
#[AsCommand(name: 'init', description: '初始化框架运行的基础文件')]
|
||||||
class InitCommand extends Command
|
class InitCommand extends Command
|
||||||
@@ -46,7 +45,9 @@ class InitCommand extends Command
|
|||||||
'Custom\\' => 'src/Custom',
|
'Custom\\' => 'src/Custom',
|
||||||
],
|
],
|
||||||
'files' => [
|
'files' => [
|
||||||
'src/Custom/global_function.php',
|
'src/Globals/global_functions.php',
|
||||||
|
'src/Globals/global_defines_app.php',
|
||||||
|
'src/Globals/global_class_alias.php',
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -185,12 +186,7 @@ class InitCommand extends Command
|
|||||||
|
|
||||||
private function getVendorPath(string $file): string
|
private function getVendorPath(string $file): string
|
||||||
{
|
{
|
||||||
try {
|
return FRAMEWORK_ROOT_DIR . $file;
|
||||||
$package_name = ZMUtil::getComposerMetadata()['name'];
|
|
||||||
} catch (\JsonException) {
|
|
||||||
throw new InitException('无法读取框架包的 composer.json', '请检查框架包完整性,或者重新安装框架包');
|
|
||||||
}
|
|
||||||
return $this->base_path . '/vendor/' . $package_name . $file;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function extractFiles(array $files, OutputInterface $output): void
|
private function extractFiles(array $files, OutputInterface $output): void
|
||||||
|
|||||||
@@ -28,7 +28,19 @@ final class ConsoleApplication extends Application
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 初始化命令
|
// 初始化命令
|
||||||
$command_classes = FileSystem::getClassesPsr4(zm_dir('src/ZM/Command'), 'ZM\\Command');
|
$command_classes = [];
|
||||||
|
// 先加载框架内置命令
|
||||||
|
$command_classes = array_merge(
|
||||||
|
$command_classes,
|
||||||
|
FileSystem::getClassesPsr4(FRAMEWORK_ROOT_DIR . '/src/ZM/Command', 'ZM\\Command')
|
||||||
|
);
|
||||||
|
// 再加载用户自定义命令(如存在)
|
||||||
|
if (is_dir(zm_dir('src/Command'))) {
|
||||||
|
$command_classes = array_merge(
|
||||||
|
$command_classes,
|
||||||
|
FileSystem::getClassesPsr4(zm_dir('src/Command'), 'Command')
|
||||||
|
);
|
||||||
|
}
|
||||||
$commands = [];
|
$commands = [];
|
||||||
foreach ($command_classes as $command_class) {
|
foreach ($command_classes as $command_class) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user