function QuickStartCommand::execute

Same name in other branches
  1. 9 core/lib/Drupal/Core/Command/QuickStartCommand.php \Drupal\Core\Command\QuickStartCommand::execute()
  2. 8.9.x core/lib/Drupal/Core/Command/QuickStartCommand.php \Drupal\Core\Command\QuickStartCommand::execute()
  3. 10 core/lib/Drupal/Core/Command/QuickStartCommand.php \Drupal\Core\Command\QuickStartCommand::execute()

File

core/lib/Drupal/Core/Command/QuickStartCommand.php, line 49

Class

QuickStartCommand
Installs a Drupal site and starts a webserver for local testing/development.

Namespace

Drupal\Core\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) : int {
    $command = $this->getApplication()
        ->find('install');
    $arguments = [
        'command' => 'install',
        'install-profile-or-recipe' => $input->getArgument('install-profile-or-recipe'),
        '--langcode' => $input->getOption('langcode'),
        '--password' => $input->getOption('password'),
        '--site-name' => $input->getOption('site-name'),
    ];
    $installInput = new ArrayInput($arguments);
    $returnCode = $command->run($installInput, $output);
    if ($returnCode === 0) {
        $command = $this->getApplication()
            ->find('server');
        $arguments = [
            'command' => 'server',
            '--host' => $input->getOption('host'),
            '--port' => $input->getOption('port'),
        ];
        if ($input->getOption('suppress-login')) {
            $arguments['--suppress-login'] = TRUE;
        }
        $serverInput = new ArrayInput($arguments);
        $returnCode = $command->run($serverInput, $output);
    }
    return $returnCode;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.