Exemplo n.º 1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     foreach ($this->config->getParameters() as $key) {
         if ($input->getOption($key) !== NULL) {
             $this->config->setParameter($key, $input->getOption($key));
             $this->getContainer()->setParameter($key, $input->getOption($key));
         }
     }
     $this->config->save();
 }
Exemplo n.º 2
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rows = array();
     foreach ($this->config->getParameters() as $key) {
         $rows[] = array($key, $this->getContainer()->getParameter($key), $this->config->getDescription($key));
     }
     $table = $this->getApplication()->getHelperSet()->get('table');
     $table->setHeaders(array('Key', 'Value', 'Description'));
     $table->setRows($rows);
     $table->render($output);
 }
Exemplo n.º 3
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $found = FALSE;
     foreach ($this->config->getParameters() as $key) {
         if ($input->getOption($key) || $input->getOption('all')) {
             $this->config->unsetParameter($key);
             $found = TRUE;
         }
     }
     if ($found) {
         $this->config->save();
     } else {
         $output->writeln('<error>No properties specified</error>');
     }
 }
Exemplo n.º 4
0
 protected function upgradeV1ToV2()
 {
     $container = $this->getContainer();
     foreach (self::$mapV1ToV2 as $from => $mapping) {
         if ($container->hasParameter($from)) {
             $oldValue = $container->getParameter($from);
             $container->setParameter($mapping['name'], $mapping['values'][$oldValue]);
             $container->getParameterBag()->remove($from);
             $this->config->setParameter($mapping['name'], $mapping['values'][$oldValue]);
             $this->config->unsetParameter($from);
         }
     }
     $container->setAlias('db', 'db.' . $container->getParameter('db_type'));
     $this->config->setParameter('version', LATEST_SCHEMA_VERSION);
 }
Exemplo n.º 5
0
 public function execute(InputInterface $input, OutputInterface $output, DialogHelper $dialog)
 {
     $default = $this->getContainer()->getParameter($this->parameter);
     $output->writeln("");
     $output->writeln("<comment>Option</comment>: {$this->parameter}");
     if ($this->description) {
         $output->writeln("<comment>Description</comment>: {$this->description}");
     }
     if ($this->example) {
         if (is_array($this->example)) {
             $output->writeln("<comment>Examples</comment>:");
             foreach ($this->example as $example) {
                 $output->writeln(" * {$example}");
             }
         } else {
             $output->writeln("<comment>Example</comment>: {$this->example}");
         }
     }
     $output->writeln("<comment>Default</comment>: {$default}");
     if ($this->ask) {
         $value = call_user_func($this->ask, $default, $input, $output, $dialog);
     } else {
         $value = $dialog->ask($output, '>', $default);
     }
     $this->config->setParameter($this->parameter, $value);
     $this->getContainer()->setParameter($this->parameter, $value);
 }
Exemplo n.º 6
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     // Deprecated options.
     if ($input->getOption('mysql_type') !== NULL) {
         if ($input->getOption('db_type') === NULL) {
             $input->setOption('db_type', 'mysql_' . $input->getOption('mysql_type'));
             $output->writeln('<error>Option "--mysql_type" is deprecated and will be removed in the future. Please use "--db_type" instead.</error>');
         } else {
             throw new \RuntimeException('Conflicting input. Use "--db_type" instead of "--mysql_type".');
         }
     }
     // Main options.
     foreach ($this->config->getParameters() as $key) {
         if ($input->getOption($key) !== NULL) {
             $this->config->setParameter($key, $input->getOption($key));
             $this->getContainer()->setParameter($key, $input->getOption($key));
         }
     }
     $this->config->save();
 }
Exemplo n.º 7
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $output->writeln("<info>" . "Welcome! amp will help setup your PHP applications by creating\n" . "databases and virtual-hosts. amp is intended for use during\n" . "development and testing.\n" . "\n" . "Please fill in a few configuration options so that we can properly\n" . "install the PHP application." . "</info>");
     $output->writeln("");
     $output->writeln("<info>=============================[ Configure Database ]=============================</info>");
     $output->writeln("");
     $output->writeln("<info>" . "Amp creates a unique database user for each generated instance.\n" . "To accomplish this amp needs GRANT-level privileges. It is\n" . "recommended that you supply the root/administrator credentials\n" . "for this task. If you wish to create a new user for amp to use\n" . "please assign it appropriate privileges eg:\n\n" . "MySQL: <fg=cyan;bg=black;option=bold>GRANT ALL ON *.* to '#user'@'localhost' IDENTIFIED BY '#pass' WITH GRANT OPTION</fg=cyan;bg=black;option=bold>\n" . "PgSQL: <fg=cyan;bg=black;option=bold>\$ createuser --superuser --createdb --createrole -P #user</fg=cyan;bg=black;option=bold>\n" . "       <fg=cyan;bg=black;option=bold>Add 'local all #user md5' to pg_hba.conf</fg=cyan;bg=black;option=bold>\n" . "       <fg=cyan;bg=black;option=bold>Test \$ psql -U #user -W template1</fg=cyan;bg=black;option=bold>" . "</info>");
     $this->askDbType()->execute($input, $output, $dialog);
     $db_type = $this->getContainer()->getParameter('db_type');
     if (in_array($db_type, array('mysql_dsn', 'pg_dsn'))) {
         $this->askDbDsn()->execute($input, $output, $dialog);
     }
     $output->writeln("");
     $output->writeln("<info>=======================[ Configure File Permissions ]========================</info>");
     $output->writeln("");
     $currentUser = \Amp\Util\User::getCurrentUser();
     $output->writeln("<info>" . "It appears that you are currently working as user \"{$currentUser}\".\n" . "\n" . "If the web server executes PHP requests as the same user, then no special\n" . "permissions are required.\n" . "\n" . "If the web server executes PHP requests as a different user (such as\n" . "\"www-data\" or \"apache\"), then special permissions will be required\n" . "for any web-writable data directories." . "</info>");
     $this->askPermType()->execute($input, $output, $dialog);
     switch ($this->config->getParameter("perm_type")) {
         case 'linuxAcl':
         case 'osxAcl':
             $this->askPermUser()->execute($input, $output, $dialog);
             break;
         case 'custom':
             $this->askPermCommand()->execute($input, $output, $dialog);
             break;
         default:
             break;
     }
     $output->writeln("");
     $output->writeln("<info>=============================[ Configure Hostnames ]=============================</info>");
     $output->writeln("<info>" . "When defining a new vhost (e.g. \"http://example-1.localhost\"), the hostname must\n" . "be mapped to an IP address.\n" . "\n" . "amp can attempt to register hostnames automatically in the /etc/hosts file.\n" . "However, if you use wildcard DNS, dnsmasq, or manually manage hostnames, then\n" . "this feature can be disabled.\n" . "</info>");
     $this->askHostsType($this->getContainer()->getParameter('hosts_file'), $this->getContainer()->getParameter('hosts_ip'))->execute($input, $output, $dialog);
     $output->writeln("");
     $output->writeln("<info>=============================[ Configure HTTPD ]=============================</info>");
     $this->askHttpdType()->execute($input, $output, $dialog);
     switch ($this->config->getParameter('httpd_type')) {
         case 'apache':
         case 'apache24':
         case 'nginx':
             $output->writeln("<info>\n" . "Whenever you create a new vhost, you may need to restart the web server.\n" . "Amp can do this automatically if you specify a command.\n" . "\n" . "NOTE: Commands based on `sudo` may require you to enter a password periodically.\n" . "</info>");
             $this->askHttpdRestartCommand()->execute($input, $output, $dialog);
             break;
         default:
     }
     switch ($this->config->getParameter('httpd_type')) {
         case 'apache':
         case 'apache24':
             $configPath = $this->getContainer()->getParameter('apache_dir');
             $output->writeln("");
             $output->writeln("<comment>Note</comment>: Please add this line to the httpd.conf or apache2.conf:");
             $output->writeln("");
             $output->writeln("  <comment>Include {$configPath}/*.conf</comment>");
             $configFiles = $this->findApacheConfigFiles();
             if ($configFiles) {
                 $output->writeln("");
                 $output->writeln("The location of httpd.conf varies, but it may be:");
                 $output->writeln("");
                 foreach ($configFiles as $configFile) {
                     $output->writeln("  <comment>{$configFile}</comment>");
                 }
             }
             $output->writeln("");
             $output->writeln("You will need to restart Apache after adding the directive -- and again");
             $output->writeln("after creating any new sites.");
             break;
         case 'nginx':
             $configPath = $this->getContainer()->getParameter('nginx_dir');
             $output->writeln("");
             $output->writeln("<comment>Note</comment>: Please ensure that nginx.conf includes this directive:");
             $output->writeln("");
             $output->writeln("  <comment>include {$configPath}/*.conf;</comment>");
             $configFiles = $this->findNginxConfigFiles();
             if ($configFiles) {
                 $output->writeln("");
                 $output->writeln("The location of nginx.conf varies, but it may be:");
                 $output->writeln("");
                 foreach ($configFiles as $configFile) {
                     $output->writeln("  <comment>{$configFile}</comment>");
                 }
             }
             $output->writeln("");
             $output->writeln("You will need to restart nginx after adding the directive -- and again");
             $output->writeln("after creating any new sites.");
             break;
         default:
     }
     $output->writeln("");
     $output->writeln("<info>===================================[ Test ]==================================</info>");
     $output->writeln("");
     $output->writeln("To ensure that amp is correctly configured, you may create a test site by running:");
     $output->writeln("");
     $output->writeln("  <comment>amp test</comment>");
     // FIXME: auto-detect "amp" vs "./bin/amp" vs "./amp"
     $this->config->save();
 }
Exemplo n.º 8
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $dialog = $this->getHelperSet()->get('dialog');
     $output->writeln("<info>" . "Welcome! amp will help setup your PHP applications by creating\n" . "databases and virtual-hosts. amp is intended for use during\n" . "development and testing.\n" . "\n" . "Please fill in a few configuration options so that we can properly\n" . "install the PHP application." . "</info>");
     $output->writeln("");
     $output->writeln("<info>=============================[ Configure MySQL ]=============================</info>");
     $output->writeln("");
     $output->writeln("<info>" . "Amp creates a unique MySQL user for each generated instance.\n" . "To accomplish this amp needs GRANT-level privileges. It is\n" . "recommended that you supply the root/administrator credentials\n" . "for this task. If you wish to create a new user for amp to use\n" . "please assign it appropriate privileges eg:\n\n" . "<fg=cyan;bg=black;option=bold>GRANT ALL ON *.* to '#user'@'localhost' IDENTIFIED BY '#pass' WITH GRANT OPTION</fg=cyan;bg=black;option=bold>" . "</info>");
     $this->config->setParameter('mysql_type', 'dsn');
     // temporary limitation
     $this->askMysqlDsn()->execute($input, $output, $dialog);
     $output->writeln("");
     $output->writeln("<info>=======================[ Configure File Permissions ]========================</info>");
     $output->writeln("");
     $currentUser = \Amp\Util\User::getCurrentUser();
     $output->writeln("<info>" . "It appears that you are currently working as user \"{$currentUser}\".\n" . "\n" . "If the web server executes PHP requests as the same user, then no special\n" . "permissions are required.\n" . "\n" . "If the web server executes PHP requests as a different user (such as\n" . "\"www-data\" or \"apache\"), then special permissions will be required\n" . "for any web-writable data directories." . "</info>");
     $this->askPermType()->execute($input, $output, $dialog);
     switch ($this->config->getParameter("perm_type")) {
         case 'linuxAcl':
         case 'osxAcl':
             $this->askPermUser()->execute($input, $output, $dialog);
             break;
         case 'custom':
             $this->askPermCommand()->execute($input, $output, $dialog);
             break;
         default:
             break;
     }
     $output->writeln("");
     $output->writeln("<info>=============================[ Configure HTTPD ]=============================</info>");
     $this->askHttpdType()->execute($input, $output, $dialog);
     switch ($this->config->getParameter('httpd_type')) {
         case 'apache':
         case 'apache24':
             $configPath = $this->getContainer()->getParameter('apache_dir');
             $output->writeln("");
             $output->writeln("<comment>Note</comment>: Please add this line to the httpd.conf or apache2.conf:");
             $output->writeln("");
             $output->writeln("  <comment>Include {$configPath}/*.conf</comment>");
             $configFiles = $this->findApacheConfigFiles();
             if ($configFiles) {
                 $output->writeln("");
                 $output->writeln("The location of httpd.conf varies, but it may be:");
                 $output->writeln("");
                 foreach ($configFiles as $configFile) {
                     $output->writeln("  <comment>{$configFile}</comment>");
                 }
             }
             $output->writeln("");
             $output->writeln("You will need to restart Apache after adding the directive -- and again");
             $output->writeln("after creating any new sites.");
             break;
         case 'nginx':
             $configPath = $this->getContainer()->getParameter('nginx_dir');
             $output->writeln("");
             $output->writeln("<comment>Note</comment>: Please ensure that nginx.conf includes this directive:");
             $output->writeln("");
             $output->writeln("  <comment>Include {$configPath}/*.conf</comment>");
             $configFiles = $this->findNginxConfigFiles();
             if ($configFiles) {
                 $output->writeln("");
                 $output->writeln("The location of nginx.conf varies, but it may be:");
                 $output->writeln("");
                 foreach ($configFiles as $configFile) {
                     $output->writeln("  <comment>{$configFile}</comment>");
                 }
             }
             $output->writeln("");
             $output->writeln("You will need to restart nginx after adding the directive -- and again");
             $output->writeln("after creating any new sites.");
             break;
         default:
     }
     $output->writeln("");
     $output->writeln("<info>===================================[ Test ]==================================</info>");
     $output->writeln("");
     $output->writeln("To ensure that amp is correctly configured, you may create a test site by running:");
     $output->writeln("");
     $output->writeln("  <comment>amp test</comment>");
     // FIXME: auto-detect "amp" vs "./bin/amp" vs "./amp"
     $this->config->save();
 }