一,创建自定义指令
php think make:command Hello hello
会生成一个app\command\
Hello
命令行指令类,我们修改内容如下:
class Hello extends Command{
//配置任务信息
protected function configure(){
$this->setName('Hello')->setDescription("计划任务 Hello");
}
//调用Hello这个类时,会自动运行execute方法
protected function execute(Input $input, Output $output){
$output->writeln('Date Crontab job start...');
$this->logic();//逻辑方法
$output->writeln('Date Crontab job end...');