console.php 834 B

1234567891011121314151617181920212223
  1. <?php
  2. use Symfony\Component\Console\Application;
  3. use Symfony\Component\Console\Input\InputInterface;
  4. use Symfony\Component\Console\Output\OutputInterface;
  5. use Symfony\Component\Console\Input\InputArgument;
  6. use Symfony\Component\Console\Input\InputOption;
  7. $console = new Application('My Silex Application', 'n/a');
  8. $console->getDefinition()->addOption(new InputOption('--env', '-e', InputOption::VALUE_REQUIRED, 'The Environment name.', 'dev'));
  9. $console->setDispatcher($app['dispatcher']);
  10. $console
  11. ->register('my-command')
  12. ->setDefinition(array(
  13. // new InputOption('some-option', null, InputOption::VALUE_NONE, 'Some help'),
  14. ))
  15. ->setDescription('My command description')
  16. ->setCode(function (InputInterface $input, OutputInterface $output) use ($app) {
  17. // do something
  18. })
  19. ;
  20. return $console;