You are here

protected function InstallCommand::execute in Drupal 10

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

File

core/lib/Drupal/Core/Command/InstallCommand.php, line 63

Class

InstallCommand
Installs a Drupal site for local testing/development.

Namespace

Drupal\Core\Command

Code

protected function execute(InputInterface $input, OutputInterface $output) : int {
  $io = new SymfonyStyle($input, $output);
  if (!extension_loaded('pdo_sqlite')) {
    $io
      ->getErrorStyle()
      ->error('You must have the pdo_sqlite PHP extension installed. See core/INSTALL.sqlite.txt for instructions.');
    return 1;
  }

  // Change the directory to the Drupal root.
  chdir(dirname(__DIR__, 5));

  // Check whether there is already an installation.
  if ($this
    ->isDrupalInstalled()) {

    // Do not fail if the site is already installed so this command can be
    // chained with ServerCommand.
    $output
      ->writeln('<info>Drupal is already installed.</info> If you want to reinstall, remove sites/default/files and sites/default/settings.php.');
    return 0;
  }
  $install_profile = $input
    ->getArgument('install-profile');
  if ($install_profile && !$this
    ->validateProfile($install_profile, $io)) {
    return 1;
  }
  if (!$install_profile) {
    $install_profile = $this
      ->selectProfile($io);
  }
  return $this
    ->install($this->classLoader, $io, $install_profile, $input
    ->getOption('langcode'), $this
    ->getSitePath(), $input
    ->getOption('site-name'));
}