PHP教程

thinkphp做定时任务

本文主要是介绍thinkphp做定时任务,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
1、配置command.php文件,目录在application/command.php

2、建立命令类文件,新建application/index/command/Test.php

<?php
namespace app\index\command;
 
use think\console\Command;
use think\console\Input;
use think\console\Output;
 
class Test extends Command
{
    protected function configure()
    {
        $this->setName('test')->setDescription('Here is the remark ');
    }
 
    protected function execute(Input $input, Output $output)
    {
        $output->writeln("TestCommand:");
    }
}
3、命令行下运行php think test ,将输出 TestCommand:,说明命令行已经成功
4在command.php文件写return ['app\index\command\remark'];
5脚本内容

// Path=写路径
// cd $Path
// php think  remark

 

这篇关于thinkphp做定时任务的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!