【发布时间】:2021-12-31 21:47:33
【问题描述】:
我正在处理 CronJob 工作由控制台命令处理的项目。这些命令是手动开发的,用于在数据库上提供不同的作业。
但现在的问题是当我们运行时
php artisan cache:clear
它首先检查在控制台文件夹下创建的所有命令,然后运行cache:clear 命令。所以很明显这个命令运行得非常慢。因为它经历了手动创建的 15 个命令。
那么有没有办法在运行迁移、缓存、配置、查看命令时忽略那些手动命令。 这些命令只有在我们手动调用时才有效?
我已经检查过使用以下方法将其隐藏,但它没有工作
使用命令隐藏属性隐藏
class updateAPILogSync extends Command
{
protected $signature = 'apilog:update';
protected $description = 'Serve function to sync the log to migrant DB';
protected $hidden = true;
}
使用 setHidden 方法隐藏
class updateAPILogSync extends Command
{
protected $signature = 'apilog:update';
protected $description = 'Serve function to sync the log to migrant DB';
public function __construct()
{
parent::__construct();
$this->setHidden(true);
}
}
请指导我。我如何可以忽略此手动命令并加快预定义命令的速度
【问题讨论】: