gpt4 book ai didi

laravel - 如何使用 Laravel 任务调度将参数传递给命令

转载 作者:行者123 更新时间:2023-12-04 01:47:38 27 4
gpt4 key购买 nike

作为官方文档,它并没有过多提及这一点。App\Console\Commands\PullUsersCommand.php 的签名如下:

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

那么,如何在App\Console\Kernel.php中给它传递参数呢

最佳答案

你可以像这样在 App\Console\Kernel.php 中调用它:

$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();

Artisan::call 门面也应该没问题。

关于laravel - 如何使用 Laravel 任务调度将参数传递给命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54613421/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com