initial 2.0 commit

This commit is contained in:
jerry
2020-08-31 10:11:06 +08:00
parent b6756179f5
commit beb1f5f063
69 changed files with 1237 additions and 2090 deletions

View File

@@ -0,0 +1,42 @@
<?php
namespace ZM;
use Exception;
use ZM\Command\BuildCommand;
use ZM\Command\InitCommand;
use ZM\Command\RunServerCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class ConsoleApplication extends Application
{
public function __construct(string $name = 'UNKNOWN') {
$version = json_decode(file_get_contents(__DIR__ . "/../../composer.json"), true)["version"] ?? "UNKNOWN";
parent::__construct($name, $version);
}
public function initEnv() {
$this->addCommands([
new RunServerCommand(), //运行主服务的指令控制器
new InitCommand() //初始化用的用于项目初始化和phar初始化
]);
if (LOAD_MODE === 0) $this->add(new BuildCommand()); //只有在git源码模式才能使用打包指令
}
/**
* @param InputInterface|null $input
* @param OutputInterface|null $output
* @return int
*/
public function run(InputInterface $input = null, OutputInterface $output = null) {
try {
return parent::run($input, $output);
} catch (Exception $e) {
die("{$e->getMessage()} at {$e->getFile()}({$e->getLine()})");
}
}
}