3 namespace Drupal\Core\Command;
5 use Symfony\Component\Console\Command\Command;
6 use Symfony\Component\Console\Input\ArrayInput;
7 use Symfony\Component\Console\Input\InputArgument;
8 use Symfony\Component\Console\Input\InputInterface;
9 use Symfony\Component\Console\Input\InputOption;
10 use Symfony\Component\Console\Output\OutputInterface;
13 * Installs a Drupal site and starts a webserver for local testing/development.
15 * Wraps 'install' and 'server' commands.
18 * This command makes no guarantee of an API for Drupal extensions.
20 * @see \Drupal\Core\Command\InstallCommand
21 * @see \Drupal\Core\Command\ServerCommand
23 class QuickStartCommand extends Command {
28 protected function configure() {
29 $this->setName('quick-start')
30 ->setDescription('Installs a Drupal site and runs a web server. This is not meant for production and might be too simple for custom development. It is a quick and easy way to get Drupal running.')
31 ->addArgument('install-profile', InputArgument::OPTIONAL, 'Install profile to install the site in.')
32 ->addOption('langcode', NULL, InputOption::VALUE_OPTIONAL, 'The language to install the site in. Defaults to en.', 'en')
33 ->addOption('site-name', NULL, InputOption::VALUE_OPTIONAL, 'Set the site name. Defaults to Drupal.', 'Drupal')
34 ->addOption('host', NULL, InputOption::VALUE_OPTIONAL, 'Provide a host for the server to run on. Defaults to 127.0.0.1.', '127.0.0.1')
35 ->addOption('port', NULL, InputOption::VALUE_OPTIONAL, 'Provide a port for the server to run on. Will be determined automatically if none supplied.')
36 ->addOption('suppress-login', 's', InputOption::VALUE_NONE, 'Disable opening a login URL in a browser.')
37 ->addUsage('demo_umami --langcode fr')
38 ->addUsage('standard --site-name QuickInstall --host localhost --port 8080')
39 ->addUsage('minimal --host my-site.com --port 80');
47 protected function execute(InputInterface $input, OutputInterface $output) {
48 $command = $this->getApplication()->find('install');
51 'command' => 'install',
52 'install-profile' => $input->getArgument('install-profile'),
53 '--langcode' => $input->getOption('langcode'),
54 '--site-name' => $input->getOption('site-name'),
57 $installInput = new ArrayInput($arguments);
58 $returnCode = $command->run($installInput, $output);
60 if ($returnCode === 0) {
61 $command = $this->getApplication()->find('server');
63 'command' => 'server',
64 '--host' => $input->getOption('host'),
65 '--port' => $input->getOption('port'),
67 if ($input->getOption('suppress-login')) {
68 $arguments['--suppress-login'] = TRUE;
70 $serverInput = new ArrayInput($arguments);
71 $returnCode = $command->run($serverInput, $output);