Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alev's avatar
Level 4

artisan command with multiple arguments: bug or error

I tried to create a new command with multiple arguments as in the example on the Laravel page: https://laravel.com/docs/6.x/artisan#arguments

I ran into an issue when making the second argument optional.

When I make the second argument mandatory it is processed correctly.

Declaration:

protected $signature = 'email:send {user} {queue}';

Input:

php artisan email:send xyz asdf

Output:

Array
(
    [command] => email:send
    [user] => xyz
    [queue] => asdf
)

But, if I make the second argument optional it is not being processed.

Declaration:

protected $signature = 'email:send {user} {--queue=}';

Input:

php artisan email:send xyz --queue=asdf

Output:

Array
(
    [command] => email:send
    [user] => xyz
)

The argument for --queue is missing in the array. It has not been processed.

Am I making a mistake, or is this a bug?

0 likes
3 replies
alev's avatar
Level 4

Aah, thanks @bobbybouwmann

Using input is wrong in that case (maybe you mistyped it?), but your example showed me to the solution.

Optional arguments are not saved in the arguments array but in the options array.

They can be accessed like this:

$this->info('queue: ' $this->option('queue'));

I was trying to access queue in the arguments array, which was wrong.

bobbybouwmann's avatar

Aah yeah typo! It should indeed be option! Glad you fixed it ;)

Please or to participate in this conversation.