-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathEchoNameCommand.php
More file actions
31 lines (22 loc) · 814 Bytes
/
Copy pathEchoNameCommand.php
File metadata and controls
31 lines (22 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
namespace App\Cli;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
class EchoNameCommand extends Command
{
protected static $defaultName = 'echo:name';
protected function configure(): void
{
$this->setDescription("Echos back the name provided at the prompt.");
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$helper = $this->getHelper('question');
$question = new Question('What\'s your name? ', 'World');
$nameAnswer = $helper->ask($input, $output, $question);
$output->writeln("Hello, $nameAnswer!");
return Command::SUCCESS;
}
}