laravel5.5的定时任务详解(demo)

https://blog.csdn.net/LJFPHP/article/details/80417552

laravel5.5的定时任务详解(demo) 这篇文章写得挺详细的。看了它我基本就会用了

php artisan make:command Test  新建任务调度文件

//这段代码意思就是在命令行执行时候的名字   php artisan test:data 就可以直接自行此文件了 ( namespace App\Console; 才顺利的命令行执行了)
protected
$signature = 'test:data';
/**
这样就相当于直接调用了StaticPagesController 用在了调度任务中
**/
use App\Http\Controllers\StaticPagesController;
.
.
.
    
    public function __construct(StaticPagesController $sp)
    {
        parent::__construct();
        $this->sp = $sp;
    }
/**
在 Kernel  任务配置调度文件  
**/


class Kernel extends ConsoleKernel
{
    protected $commands = [
        test::class,
    ];

猜你喜欢

转载自www.cnblogs.com/zhaoyang-1989/p/9670554.html