Laravel 5 命令调度器,如何传入选项 [英] Laravel 5 Command Scheduler, How to Pass in Options
问题描述
我有一个需要几天时间的命令作为选项.我在调度程序文档中没有看到如何传递选项.是否可以将选项传递给命令调度程序?
I have a command that takes in a number of days as an option. I did not see anywhere in the scheduler docs how to pass in options. Is it possible to pass options in to the command scheduler?
这是我的带有天数选项的命令:
Here is my command with a days option:
php artisan users:daysInactiveInvitation --days=30
计划是:
$schedule->command('users:daysInactiveInvitation')->daily();
最好我可以在选项中传递以下内容:
Preferably I could pass in the option something along the lines of:
$schedule->command('users:daysInactiveInvitation')->daily()->options(['days'=>30]);
推荐答案
您可以在 command()
函数中提供它们.给出的字符串实际上只是通过工匠运行,就像您通常自己在终端中运行命令一样.
You can just supply them in the command()
function. The string given is literally just run through artisan as you would normally run a command in the terminal yourself.
$schedule->command('users:daysInactiveInvitation --days=30')->daily();
参见 https://github.com/laravel/framework/blob/5.0/src/Illuminate/Console/Scheduling/Schedule.php#L36
这篇关于Laravel 5 命令调度器,如何传入选项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!