每天laravel-20160713|ScheduleRunCommand

<?php

namespace Illuminate\Console\Scheduling;

use Illuminate\Console\Command;
// namespace is very good,like a dir or a folder
class ScheduleRunCommand extends Command
{
    /**
     * The console command name.
     *
     * @var string
     */
    protected $name = 'schedule:run';// ScheduleRunCommand
    // The console command name.

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Run the scheduled commands';
    // The console command description
    // a description about the command in console

    /**
     * The schedule instance.
     *
     * @var \Illuminate\Console\Scheduling\Schedule
     */
    protected $schedule;// a string to store the instance of the Schedule

    /**
     * Create a new command instance.
     *
     * @param  \Illuminate\Console\Scheduling\Schedule  $schedule
     * @return void
     */
    public function __construct(Schedule $schedule)
    {
        $this->schedule = $schedule;

        parent::__construct();
    }// Create a new command instance.
    // a big __set
    // set the Schedule to the variable

    /**
     * Execute the console command.
     *
     * @return void
     */
    public function fire()
    {
        $events = $this->schedule->dueEvents($this->laravel);// get the events

        $eventsRan = 0;// maybe the run times

        foreach ($events as $event) {// run every events
            if (! $event->filtersPass($this->laravel)) {
                continue;
            }// check the events

            $this->line('<info>Running scheduled command:</info> '.$event->getSummaryForDisplay());
            // write a line get the wrong message
            $event->run($this->laravel);

            ++$eventsRan;// this the times
        }

        if (count($events) === 0 || $eventsRan === 0) {
            $this->info('No scheduled commands are ready to run.');
        }// info always be used like a log
    }//Execute the command
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值