function QuickStartCommand::__invoke
Same name and namespace in other branches
- main core/lib/Drupal/Core/Command/QuickStartCommand.php \Drupal\Core\Command\QuickStartCommand::__invoke()
Installs a Drupal site and starts a webserver for local development.
File
-
core/
lib/ Drupal/ Core/ Command/ QuickStartCommand.php, line 43
Class
- QuickStartCommand
- Installs a Drupal site and starts a webserver for local testing/development.
Namespace
Drupal\Core\CommandCode
public function __invoke(Application $application, OutputInterface $output, #[Argument('Install profile or recipe directory from which to install the site.')] #[Ask('Install profile or recipe directory', 'standard')] string $install_profile_or_recipe, #[Option('The language to install the site in. Defaults to \'en\'.')] string $langcode = 'en', #[Option('Set the administrator password. Defaults to a randomly generated password.')] ?string $password = NULL, #[Option('Set the site name.')] string $site_name = 'Drupal', #[Option('Provide a host for the server to run on.')] string $host = '127.0.0.1', #[Option('Provide a port for the server to run on (determined automatically if none is supplied).')] ?string $port = NULL, #[Option('Disable opening a login URL in a browser.', '', 's')] bool $suppress_login = FALSE) : int {
$command = $application->find('install');
$arguments = [
'command' => 'install',
'install-profile-or-recipe' => $install_profile_or_recipe,
'--langcode' => $langcode,
'--password' => $password,
'--site-name' => $site_name,
];
$installInput = new ArrayInput($arguments);
$returnCode = $command->run($installInput, $output);
if ($returnCode === 0) {
$command = $application->find('server');
$arguments = [
'command' => 'server',
'--host' => $host,
'--port' => $port,
];
if ($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.