You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.3 KiB
55 lines
1.3 KiB
<?php
|
|
|
|
namespace App\Console\Commands; // 定义命名空间
|
|
|
|
/**
|
|
* 清除缓存控制台命令
|
|
*
|
|
* 该命令用于清除应用程序中的缓存信息,包括配置缓存、路由缓存和视图缓存。
|
|
*/
|
|
class ClearCache extends BaseCommand
|
|
{
|
|
/**
|
|
* 控制台命令的名称和签名
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'moon:clear'; // 定义命令的名称和签名
|
|
|
|
/**
|
|
* 控制台命令的描述
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'clear moon:cache cache information'; // 描述该命令的用途
|
|
|
|
/**
|
|
* 创建一个新的命令实例.
|
|
*
|
|
* @return void
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct(); // 调用父类构造函数
|
|
}
|
|
|
|
/**
|
|
* 清除所有缓存
|
|
*
|
|
* 该方法用于处理缓存清除的逻辑,包括清除配置缓存、路由缓存和视图缓存。
|
|
*
|
|
* @return mixed
|
|
*/
|
|
public function handle()
|
|
{
|
|
// 清除配置缓存
|
|
$this->call('config:clear'); // 调用 Laravel 的 config:clear 命令
|
|
|
|
// 清除路由缓存
|
|
$this->call('route:clear'); // 调用 Laravel 的 route:clear 命令
|
|
|
|
// 清除视图缓存
|
|
$this->call('view:clear'); // 调用 Laravel 的 view:clear 命令
|
|
}
|
|
}
|