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 index10$name = $this->choice('What is your name?', ['Taylor', 'Dayle'], $defaultIndex);