ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# 自定义命令 >根目录配置文件`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 ```