4 Console eases the creation of beautiful and testable command line interfaces.
6 The Application object manages the CLI application:
8 use Symfony\Component\Console\Application;
10 $console = new Application();
13 The ``run()`` method parses the arguments and options passed on the command
14 line and executes the right command.
16 Registering a new command can easily be done via the ``register()`` method,
17 which returns a ``Command`` instance:
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;
26 ->setDefinition(array(
27 new InputArgument('dir', InputArgument::REQUIRED, 'Directory name'),
29 ->setDescription('Displays the files in the given directory')
30 ->setCode(function (InputInterface $input, OutputInterface $output) {
31 $dir = $input->getArgument('dir');
33 $output->writeln(sprintf('Dir listing for <info>%s</info>', $dir));
37 You can also register new commands via classes.
39 The component provides a lot of features like output coloring, input and
40 output abstractions (so that you can easily unit-test your commands),
41 validation, automatic help messages, ...
46 You can run the unit tests with the following command:
53 [The Console Component](http://symfony.com/doc/current/components/console.html)
55 [How to create a Console Command](http://symfony.com/doc/current/cookbook/console/console_command.html)