setDescription('Installs composer dependencies') ->addOption('no-dev', 'd', InputOption::VALUE_NONE, 'Do not install dev dependencies') ->addOption('prefer-source', 'p', InputOption::VALUE_NONE, 'Use the --prefer-source composer option'); } protected function doExecute(InputInterface $input, OutputInterface $output) { $composer = $this->container['driver.composer']; try { $output->write("Updating composer... "); $composer->command('self-update'); $output->writeln("OK"); } catch (ExecutionFailureException $e) { $output->writeln("ERROR Failed to update composer, bypassing"); } $commands = array('install', '--optimize-autoloader', '--quiet', '--no-interaction'); if ($input->getOption('prefer-source')) { $commands[] = '--prefer-source'; } try { if ($input->getOption('no-dev')) { $output->write("Installing dependencies without developer packages "); $composer->command(array_merge($commands, array('--no-dev'))); $output->writeln("OK"); } else { $output->write("Installing dependencies with developer packages "); $composer->command(array_merge($commands, array('--dev'))); $output->writeln("OK"); } } catch (ExecutionFailureException $e) { throw new RuntimeException('Unable to install composer dependencies', $e->getCode(), $e); } return 0; } }