Skip to content
This repository was archived by the owner on Nov 27, 2020. It is now read-only.

Commit 7baa790

Browse files
committed
added a hello world command in demo bundle
1 parent 8a246dc commit 7baa790

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?php
2+
3+
namespace Acme\DemoBundle\Command;
4+
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;
9+
10+
/**
11+
* Hello World command for demo purposes.
12+
*
13+
* You could also extend from Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand
14+
* to get access to the container via $this->getContainer().
15+
*
16+
* @author Tobias Schultze <http://tobion.de>
17+
*/
18+
class HelloWorldCommand extends Command
19+
{
20+
/**
21+
* {@inheritdoc}
22+
*/
23+
protected function configure()
24+
{
25+
$this
26+
->setName('acme:hello')
27+
->setDescription('Hello World example command')
28+
->addArgument('who', InputArgument::OPTIONAL, 'Who to greet.', 'World')
29+
->setHelp(<<<EOF
30+
The <info>%command.name%</info> command greets somebody or everybody:
31+
32+
<info>php %command.full_name%</info>
33+
34+
The optional argument specifies who to greet:
35+
36+
<info>php %command.full_name%</info> Fabien
37+
EOF
38+
);
39+
}
40+
41+
/**
42+
* {@inheritdoc}
43+
*/
44+
protected function execute(InputInterface $input, OutputInterface $output)
45+
{
46+
$output->writeln(sprintf('Hello <comment>%s</comment>!', $input->getArgument('who')));
47+
}
48+
}

0 commit comments

Comments
 (0)