Laravel命令在循环中执行

时间:2017-03-20 16:56:43

标签: php laravel symfony redis

在循环中执行命令App / Console / Commands / ImportSecond.php是否有任何特定原因?

它在作业App / Jobs / ImportFirst.php的脚本末尾启动:

public function handle()
{ 
    $file = $this->file;

    $extension = \File::extension($file);
    $name = \File::name($file);

    $lors = \DB::table('settings')
            ->where('parameter', 'mb_mode')
            ->first();

    if($lors->value == 'seg') {
           \Artisan::call('import:second', ["bid" => $bid, 'filename' => "$name.$extension"]);
    } 
}

作业本身由BController.php中的inject_file方法调用:

public function inject_file($bid)
{
     $name = \Input::file('file')->getClientOriginalName(); 
     \Input::file('file')->move(storage_path() . '/bids/', $name); 
     $this->dispatch (new ImportFirst($bid, \Input::file('file')->getClientOriginalName())); 
     return "OK";
}

总结: BController.php将ImportFirst作业调度到Redis,它最后启动了ImportSecond

BController.php - > ImportFirst(工作) - > ImportSecond(命令)

Laravel版本:5.1.26 - 队列驱动程序:Redis

0 个答案:

没有答案