Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelper('dialog');
     $style = new OutputFormatterStyle('blue');
     $output->getFormatter()->setStyle('sample', $style);
     $vhostFilename = $input->getOption('vhost-filename');
     if (null === $vhostFilename) {
         $vhostFilename = $input->getArgument('serverName');
     }
     $vhost = new Vhost($vhostFilename);
     $vhost->setServerName($input->getArgument('serverName'))->setDocumentRoot($input->getArgument('documentRoot'))->setEnv($input->getOption('env'));
     $builder = new NginxBuilder($vhost);
     // Dumping a preview
     $output->writeln("\nThe vhost file <info>{$builder->getVhostAvailablePath()}</info> will look like:\n");
     $output->writeln("<sample>{$builder->getTemplate()}</sample>");
     // Confirm generation
     if (!$dialog->askConfirmation($output, "\n<question>Do you confirm the vhost generation?</question> ", true)) {
         $output->writeln("\n<error>Canceled!!</error> The vhost has not been created due to user interruption\n");
         return;
     }
     $builder->createVhost()->restartServer();
     $output->writeln("\n<info>Awesome!!</info> Your vhost has been successfully created and enabled");
     $output->writeln("\nYou should append this line to your <info>/etc/hosts</info> file:\n");
     $output->writeln("<sample>127.0.0.1\t{$vhost->getServerName()}</sample>\n");
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelper('dialog');
     $vhost = new Vhost($input->getArgument('vhostFilename'));
     $builder = new NginxBuilder($vhost);
     $output->writeln("\nThe following files are going to be <error>deleted</error>:\n");
     foreach ($builder->getGeneratedFiles() as $file) {
         $output->writeln("<comment>{$file}</comment>");
     }
     // Confirm generation
     if (!$dialog->askConfirmation($output, "\n<question>Do you confirm the removal of the vhost?</question> ", true)) {
         $output->writeln("\n<error>Canceled!!</error> The vhost has not been deleted due to user interruption\n");
         return;
     }
     $builder->deleteVhost()->restartServer();
     $output->writeln("\n<info>Awesome!!</info> Your vhost has been successfully deleted\n");
 }