Artisan command parameters

When creating Artisan command, you can ask the input in variety of ways: $this->confirm(), $this->anticipate(), $this->choice().

1// Yes or no?
2if ($this->confirm('Do you wish to continue?')) {
3 //
4}
5 
6// Open question with auto-complete options
7$name = $this->anticipate('What is your name?', ['Taylor', 'Dayle']);
8 
9// One of the listed options with default index
10$name = $this->choice('What is your name?', ['Taylor', 'Dayle'], $defaultIndex);

Like our articles?

Become a Premium Member for $129/year or $29/month
What else you will get:
  • 22 courses (477 lessons, total 38 h 20 min)
  • 2 long-form tutorials (one new every week)
  • access to project repositories
  • access to private Discord