You are here

protected function QuickStartCommand::execute in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Command/QuickStartCommand.php \Drupal\Core\Command\QuickStartCommand::execute()

File

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

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) {
  $command = $this
    ->getApplication()
    ->find('install');
  $arguments = [
    'command' => 'install',
    'install-profile' => $input
      ->getArgument('install-profile'),
    '--langcode' => $input
      ->getOption('langcode'),
    '--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;
}