3 namespace Acme\DemoBundle\Command
;
5 use Symfony\Component\Console\Command\Command
;
6 use Symfony\Component\Console\Input\InputArgument
;
7 use Symfony\Component\Console\Input\InputInterface
;
8 use Symfony\Component\Console\Output\OutputInterface
;
11 * Hello World command for demo purposes.
13 * You could also extend from Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
14 * to get access to the container via $this->getContainer().
16 * @author Tobias Schultze <http://tobion.de>
18 class HelloWorldCommand
extends Command
23 protected function configure()
26 ->setName('acme:hello')
27 ->setDescription('Hello World example command')
28 ->addArgument('who', InputArgument
::OPTIONAL
, 'Who to greet.', 'World')
30 The <info>%command.name%</info> command greets somebody or everybody:
32 <info>php %command.full_name%</info>
34 The optional argument specifies who to greet:
36 <info>php %command.full_name%</info> Fabien
44 protected function execute(InputInterface
$input, OutputInterface
$output)
46 $output->writeln(sprintf('Hello <comment>%s</comment>!', $input->getArgument('who')));