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.
aquaculture/app/Console/Commands/CacheOptimize.php

52 lines
1.2 KiB

<?php
namespace App\Console\Commands; // 定义命名空间
/**
* 缓存优化控制台命令
*
* 该命令用于优化配置和路由缓存,以提高网站的运行速度。
*/
class CacheOptimize extends BaseCommand
{
/**
* 控制台命令的名称和签名
*
* @var string
*/
protected $signature = 'moon:cache'; // 定义命令的名称和签名
/**
* 控制台命令的描述
*
* @var string
*/
protected $description = 'Cache routing, configure information, to speed up the website running speed'; // 描述该命令的用途
/**
* 创建一个新的命令实例.
*
* @return void
*/
public function __construct()
{
parent::__construct(); // 调用父类构造函数
}
/**
* 执行缓存命令
*
* 该方法用于处理缓存优化的逻辑,包括优化配置和路由缓存。
*
* @return mixed
*/
public function handle()
{
// 优化配置并缓存配置文件
$this->call('config:cache'); // 调用 Laravel 的 config:cache 命令
// 优化路由并缓存路由信息
$this->call('route:cache'); // 调用 Laravel 的 route:cache 命令
}
}