NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
# 自定义命令 >根目录配置文件`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 ```