Laravel 5.7 Schedule Command

This is a post to clarify more details for calling commands in Laravel schedule and pass parameters to it. This is the command class App\Console\Commands\PullUsersCommand.phpsignature :

protected $signature = 'pull:users {startTime} {endTime} {minutes=10} {--flag} {--star=}';

You could call it in App\Console\Kernel.php like this

$schedule->command('pull:users', [
    time(),  // captured with $this->argument('startTime') in command class.
    time(),  // captured with $this->argument('endTime') in command class.
    30,      // captured with $this->argument('minutes') in command class.
    '--flag',// should be without any value, just the option name, and would be captured by $this->option('minutes').
    '--star'=>12, // would be captured by $this->option('star').
])->daily();

It should be okay with Artisan::call facade too.

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,151评论 0 10
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 13,147评论 0 13
  • 一直都保持着写写随笔的小爱好,虽然没有坚持天天都写,但也会在每逢灵感之时,欣然提笔,写下一段文字。 我喜欢将许多的...
    枫之心阅读 2,849评论 0 0
  • 本文由币车HIT(biche.yaofache.com)大V养成计划支持 小韭菜们入场干的第一件...
    韭菜开花阅读 2,958评论 0 0
  • 淳熙丙申至日,予过维扬。夜雪初霁,荠麦弥望。 入其城,则四顾萧条,寒水自碧,暮色渐起, 戍角悲吟。予怀怆然,感慨今...
    赵一桃不姓赵阅读 4,536评论 0 2