Merge pull request #448 from corpsee/installation-fix

Installation fix
This commit is contained in:
Dan Cryer 2014-06-13 13:53:43 +01:00
commit 48f3ebf440

View file

@ -12,6 +12,7 @@ namespace PHPCI\Command;
use Exception; use Exception;
use PDO; use PDO;
use b8\Config;
use b8\Database; use b8\Database;
use b8\Store\Factory; use b8\Store\Factory;
use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Command\Command;
@ -89,13 +90,13 @@ class InstallCommand extends Command
$conf['b8']['database'] = $db; $conf['b8']['database'] = $db;
$conf['phpci']['url'] = $dialog->askAndValidate( $conf['phpci']['url'] = $dialog->askAndValidate(
$output, $output,
'Your PHPCI URL (without trailing slash): ', 'Your PHPCI URL ("http://phpci.local" for example): ',
function ($answer) { function ($answer) {
if (!filter_var($answer, FILTER_VALIDATE_URL)) { if (!filter_var($answer, FILTER_VALIDATE_URL)) {
throw new Exception('Must be a valid URL'); throw new Exception('Must be a valid URL');
} }
return $answer; return rtrim($answer, '/');
}, },
false false
); );
@ -107,8 +108,10 @@ class InstallCommand extends Command
/** /**
* Check PHP version, required modules and for disabled functions. * Check PHP version, required modules and for disabled functions.
* @param OutputInterface $output * @param OutputInterface $output
* @throws \Exception
*/ */
protected function checkRequirements(OutputInterface $output) protected function checkRequirements(OutputInterface $output)
{ {
$output->write('Checking requirements...'); $output->write('Checking requirements...');
@ -159,8 +162,8 @@ class InstallCommand extends Command
/** /**
* Try and connect to MySQL using the details provided. * Try and connect to MySQL using the details provided.
* @param array $db * @param array $db
* @param OutputInterface $output * @param OutputInterface $output
* @return bool * @return bool
*/ */
protected function verifyDatabaseDetails(array $db, OutputInterface $output) protected function verifyDatabaseDetails(array $db, OutputInterface $output)
@ -209,6 +212,10 @@ class InstallCommand extends Command
$output->writeln('<info>OK</info>'); $output->writeln('<info>OK</info>');
} }
/**
* @param OutputInterface $output
* @param DialogHelper $dialog
*/
protected function createAdminUser(OutputInterface $output, DialogHelper $dialog) protected function createAdminUser(OutputInterface $output, DialogHelper $dialog)
{ {
// Try to create a user account: // Try to create a user account:
@ -235,6 +242,8 @@ class InstallCommand extends Command
$user->setIsAdmin(1); $user->setIsAdmin(1);
$user->setHash(password_hash($adminPass, PASSWORD_DEFAULT)); $user->setHash(password_hash($adminPass, PASSWORD_DEFAULT));
$this->reloadConfig();
$store = Factory::getStore('User'); $store = Factory::getStore('User');
$store->save($user); $store->save($user);
@ -246,6 +255,19 @@ class InstallCommand extends Command
} }
} }
protected function reloadConfig()
{
$configFile = PHPCI_DIR . 'PHPCI/config.yml';
$config = Config::getInstance();
if (file_exists($configFile)) {
$config->loadYaml($configFile);
}
}
/**
* @param OutputInterface $output
*/
protected function verifyNotInstalled(OutputInterface $output) protected function verifyNotInstalled(OutputInterface $output)
{ {
if (file_exists(PHPCI_DIR . 'PHPCI/config.yml')) { if (file_exists(PHPCI_DIR . 'PHPCI/config.yml')) {