任务调度的可选参数

获取输入的参数和可选项

# 获取参数,可指定键
$this->argument();

# 获取用户手动输入的参数
$this->option();

创建命令

php artisan make:command Test

必填参数

protected $signature = 'test {type}';

可选参数

test {type?}

参数给默认值

test {type=1}

参数接收一系列值

test {type*} 使用时用空格分割开 php artisan test 1 2 3

代码接收到的是一个数组 $params = $this->argument('test');

可选项

test {--ids=*} 使用方式如下

php artisan test --ids=1 --ids=2 --ids=3