多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# 自定义命令 >根目录配置文件`config`下`console.php`中添加 ``` return [ // 指令定义 'commands' => [ 'menu' => 'app\command\updateMenu', ], ]; ``` 目录`app\command\`下定义命令实现类,比如实现自动创建一个services类: ``` <?php declare (strict_types=1); namespace app\command; use app\common\repositories\system\auth\MenuRepository; use think\console\Command; use think\console\Input; use think\console\Output; class FormatMenuPath extends Command { protected function configure() { // 指令配置 $this->setName('menu:format') ->setDescription('the format menu command'); } protected function execute(Input $input, Output $output) { $output->writeln('开启修复'); $menuRepository = app()->make(MenuRepository::class); $menuRepository->formatPath(0); $menuRepository->formatPath(1); $output->writeln('执行成功'); } } ``` 执行创建命令 ``` php think menu ```