Defining Arguments

Arguments

To add arguments to your command you can use the Argument attribute.

use Illuminate\Console\Command;
use WendellAdriel\Virtue\Commands\Attributes\Argument;
use WendellAdriel\Virtue\Commands\Concerns\Virtue;

#[Argument(name: 'optional', required: false, description: 'Optional parameter')]
#[Argument(name: 'required')]
final class TestCommand extends Command
{
    use Virtue;

    protected $name = 'app:test';

    protected $description = 'Command description';

    public function handle()
    {
        // Command code here
    }
}

These are the available properties to define your optional arguments:

Optional Arguments

To add optional arguments to your command, you can also use the OptionalArgument attribute.

These are the available properties to define your optional arguments:

Required Arguments

To add required arguments to your command, you can also use the RequiredArgument attribute.

These are the available properties to define your required arguments:

Last updated

Was this helpful?