Deploys application.

@param InputInterface  $input
@param OutputInterface $output
163958
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $rootDir = $this->getRootDir();
        $stagingName = $input->getOption('staging-name');
        $stagingPath = $this->getCapistranoDir().'/deploy/';
        $staging = sprintf('%s%s.rb', $stagingPath, $stagingName);

        $output->setVerbosity(OutputInterface::VERBOSITY_VERBOSE);
        $this->sayWelcome($output);

        if (false === file_exists($staging)) {
            $yamlStaging = sprintf('%s/config/rch/staging/%s.yml', $rootDir, $stagingName);

            if (false === file_exists($yamlStaging)) {
                throw new InvalidArgumentException(sprintf('Unable to find staging with name %s', $stagingName));
            }

            $params = $this->parseYamlStaging($yamlStaging);
            $generator = new StagingGenerator($params, $stagingPath, $stagingName);

            $this->generate($generator);
        }

        $builder = new ProcessBuilder(['bundle', 'exec', 'cap', $stagingName, 'deploy']);
        $builder->setTimeout(null);
        $process = $builder->getProcess();

        $process->run(function ($type, $buffer) use ($output) {
            $output->write(sprintf('<info>%s</info>', $buffer));
        });

        if (!$process->isSuccessful()) {
            $output->writeln(PHP_EOL);
            $output->writeln('<error>Deployment failed</error>');
            $output->writeln(
                sprintf('<error>Execute <comment>cap %s deploy --trace</comment> for more details</error>', $stagingName)
            );

            return $process->getExitCode();
        }

        return $output->writeln(
            '<info>Project successfully deployed !</info>'
        );
    }
323992
protected function execute(InputInterface $input, OutputInterface $output)
	{
		$this->setupEnvironment('site', $input, $output);

		$version = new \JVersion;

		if ($input->getOption('short'))
		{
			$result = $version->getShortVersion();
		}
		elseif ($input->getOption('release'))
		{
			$result = $version->RELEASE;
		}
		else
		{
			$result = $version->getLongVersion();
		}
		$output->writeln($result);
	}
761302
public function execute(InputInterface $input, OutputInterface $output)
    {
        $runner = $this->commandDefinition->getRunner();
        $runner();
    }
617433
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $formatter = $this->getHelper('formatter');
        $templates = $this
            ->templateManager
            ->loadTemplates();

        foreach ($templates as $template) {
            $formattedLine = $formatter->formatSection(
                'OK',
                'Template "' . $template['bundle'] . '" installed'
            );

            $output->writeln($formattedLine);
        }
    }
915365
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->output = $output;
        $config = $this->parameters;
        $recursive = $input->getOption('recursive');
        $machine = $input->getOption('machine') ? $config->get('dotfiles.machine_name') : 'defaults';
        $backupDir = $config->get('dotfiles.backup_dir')."/src/$machine/home";
        $sourcePath = $input->getArgument('path');

        // detect source path
        $originPath = $this->detectPath($sourcePath);
        $relativePath = Toolkit::getRelativePath($originPath);
        if (0 === strpos($relativePath, '.')) {
            $relativePath = substr($relativePath, 1);
        }
        $relativePath = str_replace('.'.$sourcePath, $sourcePath, $relativePath);
        $targetPath = $backupDir.'/'.$relativePath;

        Toolkit::ensureDir($backupDir);

        $basename = basename($sourcePath);
        if (0 === strpos($basename, '.')) {
            $targetPath = str_replace('.'.$sourcePath, $basename, $targetPath);
        }

        if (is_dir($originPath)) {
            $this->doAddDir($originPath, $targetPath, $recursive);
        } else {
            $this->doAddFile($originPath, $targetPath);
        }
    }
823967
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $migrationsTemplate = base_path().'/storage/migrations';
        $migration = $input->getArgument('migration');

        $file = file($migrationsTemplate);
        foreach ($file as $item) {
            $itemexp = explode('_', str_replace('.php', '', $item));

            for ($i = 0; $i < 4; $i++) {
                array_shift($itemexp);
            }

            $name = trim(implode('_', $itemexp));

            if ($migration == $name) {
                $path = trim(base_path().'/database/'.$item);
                if (file_exists($path)) {
                    $output->writeln('<info>Rolling back migration</info>');
                    foreach ($itemexp as $key => $ie) {
                        $itemexp[$key] = ucwords($ie);
                    }
                    $mn = str_replace('_', '', implode('_', $itemexp));
                    shell_exec('php cli db:rollback '.$mn);
                    $output->writeln('<info>Removing migration from file system</info>');
                    unlink($path);
                    $output->writeln('<info>Removing from migrations cache</info>');

                    $key = array_keys($file, $item);
                    array_splice($file, $key[0]);

                    $handle = fopen($migrationsTemplate, 'w');
                    foreach ($file as $f) {
                        fwrite($handle, $f);
                    }
                    fclose($handle);
                } else {
                    $output->writeln("<error>$migration does not exist!</error>");
                }
            }
        }
    }
936606
public function execute(InputInterface $input, OutputInterface $output)
    {
        $description = $input->getArgument('description');
        $time        = date('YmdHis');
        $classname   = $this->generateClassName($time, $description);
        $filepath    = APPDIR.'/src/'.$this->namespaceToPath().$classname.'.php';

        if (! is_dir(dirname($filepath))) {
            mkdir(dirname($filepath), 0775, true);
        }

        $view = $this->newMigrationView;

        $view->description($description);
        $view->classname($classname);
        $view->timestamp($time);

        file_put_contents($filepath, (string) $view);

        $message = '  Created migration file '.$filepath;

        // Output message padded by newlines
        $output->write(['', $message, ''], true);
    }
1139589
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $this->getBaseFiles();

        foreach ($this->languages as $lang) {
            $this->processLanguage($output, $lang);
        }
    }
1369877
protected function execute(InputInterface $input, OutputInterface $output)
    {
        if ($this->getApplication() instanceof Application) {
            $this->createFileTemplate($input, $output, $this->getApplication()->endpointPath());
        }
    }
24071
protected function execute(InputInterface $input, OutputInterface $output) : void
    {
        $io     = $this->getIO($input, $output);
        $config = $this->getConfig($input->getOption('configuration'));

        $configurator = new Creator($io, $config);
        $configurator->force($input->getOption('force'))
                     ->extend($input->getOption('extend'))
                     ->advanced($input->getOption('advanced'))
                     ->run();
    }
1063373
protected function execute(InputInterface $input, OutputInterface $output)
    {
        parent::execute($input, $output);
        $this->schema   = $input->getArgument('schema');

        if (!$this->schema) {
            $this->schema = 'public';
        }

        $this->prefix_dir = $input->getOption('prefix-dir');
        $this->prefix_ns  = $input->getOption('prefix-ns');
        $this->flexible_container = $input->getOption('flexible-container');
    }
1175632
protected function execute(InputInterface $input, OutputInterface $output): void
    {
        /** @var AssetsInstallerInterface $assetsInstaller */
        $assetsInstaller = $this->getContainer()->get('sylius.theme.asset.assets_installer');
        if ($assetsInstaller instanceof OutputAwareInterface) {
            $assetsInstaller->setOutput($output);
        }

        $symlinkMask = AssetsInstallerInterface::HARD_COPY;

        if ($input->getOption('symlink')) {
            $symlinkMask = max($symlinkMask, AssetsInstallerInterface::SYMLINK);
        }

        if ($input->getOption('relative')) {
            $symlinkMask = max($symlinkMask, AssetsInstallerInterface::RELATIVE_SYMLINK);
        }

        $assetsInstaller->installAssets($this->getTargetDir($input), $symlinkMask);
    }
1140758
public function runApplication(InputInterface $input = null, OutputInterface $output = null): void
    {
        $this->getFactory()->createApplication()->run($input, $output);
    }
1014081
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $start = microtime(true);

        $this->setOutput($output);
        $this->setVerbosity($output->getVerbosity());

        if ($input->getOption('child') && $output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL) {
            $this->setVerbosity(self::VERBOSITY_CHILD);
        }

        $this->getContainer()->get('ez_migration_bundle.step_executed_listener.tracing')->setOutput($output);

        $migrationService = $this->getMigrationService();

        $force = $input->getOption('force');

        $toExecute = $this->buildMigrationsList($input->getOption('path'), $migrationService, $force);

        if (!count($toExecute)) {
            $output->writeln('<info>No migrations to execute</info>');
            return 0;
        }

        $this->printMigrationsList($toExecute, $input, $output);

        if (!$input->getOption('child')) {
            // ask user for confirmation to make changes
            if (!$this->askForConfirmation($input, $output)) {
                return 0;
            }
        }

        if ($input->getOption('separate-process')) {
            $builder = new ProcessBuilder();
            $executableFinder = new PhpExecutableFinder();
            if (false !== $php = $executableFinder->find()) {
                $builder->setPrefix($php);
            }
            $builderArgs = $this->createChildProcessArgs($input);
        }

        // For cli scripts, this means: do not die if anyone yanks out our stdout.
        if ($input->getOption('survive-disconnected-tty')) {
            ignore_user_abort(true);
        }

        // allow forcing handling of sigchild. Useful on eg. Debian and Ubuntu
        if ($input->getOption('force-sigchild-enabled')) {
            Process::forceSigchildEnabled(true);
        }

        $aborted = false;
        $executed = 0;
        $failed = 0;
        $skipped = 0;
        $total = count($toExecute);

        /** @var MigrationDefinition $migrationDefinition */
        foreach ($toExecute as $name => $migrationDefinition) {

            // let's skip migrations that we know are invalid - user was warned and he decided to proceed anyway
            if ($migrationDefinition->status == MigrationDefinition::STATUS_INVALID) {
                $output->writeln("<comment>Skipping $name</comment>");
                $skipped++;
                continue;
            }

            $this->writeln("<info>Processing $name</info>");

            if ($input->getOption('separate-process')) {

                try {
                    $this->executeMigrationInSeparateProcess($migrationDefinition, $migrationService, $builder, $builderArgs);

                    $executed++;
                } catch (\Exception $e) {
                    $failed++;


                    $errorMessage = $e->getMessage();
                    // we probably have already echoed the error message while the subprocess was executing, avoid repeating it
                    if ($errorMessage != $this->subProcessErrorString) {
                        if ($e instanceof AfterMigrationExecutionException) {
                            $errorMessage = "Failure after migration end! Reason: " . $errorMessage;
                        } else {
                            $errorMessage = "Migration failed! Reason: " . $errorMessage;
                        }

                        $this->writeErrorln("\n<error>$errorMessage</error>");
                    }

                    if (!$input->getOption('ignore-failures')) {
                        $aborted = true;
                        break;
                    }
                }

            } else {

                try {
                    $this->executeMigrationInProcess($migrationDefinition, $force, $migrationService, $input);

                    $executed++;
                } catch (\Exception $e) {
                    $failed++;

                    $this->writeErrorln("\n<error>Migration failed! Reason: " . $e->getMessage() . "</error>");

                    if (!$input->getOption('ignore-failures')) {
                        $aborted = true;
                        break;
                    }
                }

            }
        }

        $missed = $total - $executed - $failed - $skipped;

        if ($aborted) {
            if ($missed > 0) {
                $this->writeErrorln("\n<error>Migration execution aborted</error>");
            }
        } else {
            // NB: as per the Sf doc at https://symfony.com/doc/2.7/console/calling_commands.html, the 'cache:clear'
            // command should be run 'at the end', as they change some class definitions
            if ($input->getOption('clear-cache')) {
                $command = $this->getApplication()->find('cache:clear');
                $inputArray = new ArrayInput(array('command' => 'cache:clear'));
                $command->run($inputArray, $output);
            }
        }

        $this->writeln("\nExecuted $executed migrations, failed $failed, skipped $skipped" . ($missed ? ", missed $missed" : ''));

        $time = microtime(true) - $start;
        if ($input->getOption('separate-process')) {
            // in case of using subprocesses, we can not measure max memory used
            $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs</info>");
        } else {
            $this->writeln("<info>Time taken: ".sprintf('%.2f', $time)." secs, memory: ".sprintf('%.2f', (memory_get_peak_usage(true) / 1000000)). ' MB</info>');
        }

        return $failed;
    }
69036
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $root = $this->getContainer()->getParameter('kernel.root_dir');
        chdir("$root/..");
        $path = "$root/Resources/gettext/messages.pot";
        $languages = $input->getArgument('languages');
        $results = $this->initializeFromTemplate($path, $languages);
        foreach ($results as $filename => $status) {
            $output->writeln("$status: $filename");
        }
    }
660074
protected function runCommand(InputInterface $input, OutputInterface $output)
    {
        $appName = $input->getArgument('app-name');
        $this
            ->repositoryBucket->findRepository($appName)
            ->deleteTokens();
    }
344822
protected function execute(InputInterface $input, OutputInterface $output)
    {
        $migrationsTemplate = base_path().'/storage/migrations';
        $migration = $input->getArgument('migration');

        $file = file($migrationsTemplate);
        $items = '';
        $goahead = false;
        foreach ($file as $fn) {
            $item = $fn;
            $nameexp = explode('_', $item);

            for ($i = 0; $i < 4; $i++) {
                array_shift($nameexp);
            }

            foreach ($nameexp as $key => $i) {
                $nameexp[$key] = ucwords($i);
            }

            $name = str_replace('_', '', str_replace('.php', '', implode('_', $nameexp)));

            $path = base_path().'/database/'.$item;

            if (file_exists(trim($path))) {
                if (empty($migration)) {
                    $goahead = true;
                } else {
                    if ($migration == trim($name)) {
                        $goahead = true;
                    }
                }

                if ($goahead) {
                    // update migrations table
                    if ($this->isMigrated($item, $output)) {
                        $output->writeln('Item: '.trim($name).' is already pushed to the database');
                    } else {
                        $output->writeln('Migrating '.trim($name).' migration');
                        require_once trim($path);
                        $class = '\\'.trim($name);
                        $c = new $class();
                        $c->up();
                        $this->changeMigrationTable($item);
                    }
                }
            }
        }
    }