function ServerCommand::execute
Overrides Command::execute
File
-
core/
lib/ Drupal/ Core/ Command/ ServerCommand.php, line 61
Class
- ServerCommand
- Runs the PHP webserver for a Drupal site for local testing/development.
Namespace
Drupal\Core\CommandCode
protected function execute(InputInterface $input, OutputInterface $output) : int {
$io = new SymfonyStyle($input, $output);
$host = $input->getOption('host');
$port = $input->getOption('port');
if (!$port) {
$port = $this->findAvailablePort($host);
}
if (!$port) {
$io->getErrorStyle()
->error('Unable to automatically determine a port. Use the --port to hardcode an available port.');
}
try {
$kernel = $this->boot();
} catch (ConnectionNotDefinedException) {
$io->getErrorStyle()
->error("No installation found. Use the 'install' command.");
return 1;
}
return $this->start($host, $port, $kernel, $input, $io);
}