README.md
1Console Component
2=================
3
4Console eases the creation of beautiful and testable command line interfaces.
5
6The Application object manages the CLI application:
7
8 use Symfony\Component\Console\Application;
9
10 $console = new Application();
11 $console->run();
12
13The ``run()`` method parses the arguments and options passed on the command
14line and executes the right command.
15
16Registering a new command can easily be done via the ``register()`` method,
17which returns a ``Command`` instance:
18
19 use Symfony\Component\Console\Input\InputInterface;
20 use Symfony\Component\Console\Input\InputArgument;
21 use Symfony\Component\Console\Input\InputOption;
22 use Symfony\Component\Console\Output\OutputInterface;
23
24 $console
25 ->register('ls')
26 ->setDefinition(array(
27 new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'),
28 ))
29 ->setDescription('Displays the files in the given directory')
30 ->setCode(function (InputInterface $input, OutputInterface $output) {
31 $dir = $input->getArgument('dir');
32
33 $output->writeln(sprintf('Dir listing for <info>%s</info>', $dir));
34 })
35 ;
36
37You can also register new commands via classes.
38
39The component provides a lot of features like output coloring, input and
40output abstractions (so that you can easily unit-test your commands),
41validation, automatic help messages, ...
42
43Tests
44-----
45
46You can run the unit tests with the following command:
47
48 $ cd path/to/Symfony/Component/Console/
49 $ composer.phar install
50 $ phpunit
51
52Third Party
53-----------
54
55`Resources/bin/hiddeninput.exe` is a third party binary provided within this
56component. Find sources and license at https://github.com/Seldaek/hidden-input.
57
58Resources
59---------
60
61[The Console Component](http://symfony.com/doc/current/components/console.html)
62
63[How to create a Console Command](http://symfony.com/doc/current/cookbook/console/console_command.html)
64