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(); }
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); }
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); }
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(); }
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(); }