{{wikiTitle}}
自定义指令
复制链接
编辑文档
自定义命令
根目录配置文件
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
现有命令
php think spu #把所有商品同步一下SPU表
php think menu:format #整理路由权限
php think clear:attachment #清除缓存素材
php think version:update #版本更新
php think clear:merchant #清除所有 除配置相关之外的数据
php think clear:redundancy #清除所有已删除的商户的商品相关数据
php think reset:password #重制平台管理员的密码
php think reset:imagePath #修改图片地址前缀
php think clear:cache #清除登录限制
评论({{cateWiki.comment_num}})
最新
最早
{{cateWiki.page_view_num}}人看过该文档
评论(0)
最新
最早
917人看过
登录/注册
即可发表评论
{{item.user ? item.user.nickname : ''}}
(自评)
{{item.content}}
搜索结果
为您找到{{wikiCount}}条结果
{{item.page_view_num}}
{{item.like ? item.like.like_num : 0}}
{{item.comment ? item.comment.comment_num : 0}}
位置:
{{path.name}}
{{(i+1) == getCataloguePathData(item.catalogue).length ? '':'/'}}
