Symfony\Component\Console\Application::doRun PHP Method

doRun() public method

Runs the current application.
public doRun ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output ) : integer
$input Symfony\Component\Console\Input\InputInterface An Input instance
$output Symfony\Component\Console\Output\OutputInterface An Output instance
return integer 0 if everything went fine, or an error code
    public function doRun(InputInterface $input, OutputInterface $output)
    {
        if (true === $input->hasParameterOption(array('--version', '-V'), true)) {
            $output->writeln($this->getLongVersion());
            return 0;
        }
        $name = $this->getCommandName($input);
        if (true === $input->hasParameterOption(array('--help', '-h'), true)) {
            if (!$name) {
                $name = 'help';
                $input = new ArrayInput(array('command_name' => $this->defaultCommand));
            } else {
                $this->wantHelps = true;
            }
        }
        if (!$name) {
            $name = $this->defaultCommand;
            $input = new ArrayInput(array('command' => $this->defaultCommand));
        }
        // the command name MUST be the first element of the input
        $command = $this->find($name);
        $this->runningCommand = $command;
        $exitCode = $this->doRunCommand($command, $input, $output);
        $this->runningCommand = null;
        return $exitCode;
    }

Usage Example

Example #1
0
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $container = $this->container;
     $container->set('ui.input', $input);
     $container->set('ui.output', $output);
     $container->get('logger.handler')->setOutput($output);
     foreach ($container->getByPrefix('commands') as $command) {
         $this->add($command);
     }
     if ($input->hasParameterOption(array('--tags', '-t'))) {
         $tags = $input->getParameterOption(array('--tags', '-t'));
         $tags = explode(',', $tags);
         $container->setParameter('filter.tags', $tags);
         $container->get('logger')->addDebug('Filtered using tags', array('tags' => $tags));
     }
     if ($input->hasParameterOption(array('--coverage', '-r'))) {
         $container->setParameter('coverage.enabled', true);
     }
     $event = new GenericEvent($container);
     $container->get('dispatcher')->dispatch(ApplicationEvents::initialize, $event);
     $command = $this->getCommandName($input);
     if (trim($command) === '') {
         $input = new StringInput('start');
     }
     return parent::doRun($input, $output);
 }
All Usage Examples Of Symfony\Component\Console\Application::doRun