Check prerequisites in console installer, too

This commit is contained in:
Franz Liedke 2015-09-03 08:42:16 +02:00
parent 942db77416
commit 3c9d851889
4 changed files with 37 additions and 7 deletions

View File

@ -62,11 +62,22 @@ class InstallCommand extends Command
{
$this->init();
$prerequisites = $this->getPrerequisites();
$prerequisites->check();
$errors = $prerequisites->getErrors();
if (empty($errors)) {
$this->info('Installing Flarum...');
$this->install();
$this->info('DONE.');
} else {
$this->output->writeln(
'<error>Please fix the following errors before we can continue with the installation.</error>'
);
$this->showErrors($errors);
}
}
protected function init()
@ -275,4 +286,23 @@ class InstallCommand extends Command
{
return base_path('../config.php');
}
/**
* @return \Flarum\Install\Prerequisites\Prerequisite
*/
protected function getPrerequisites()
{
return $this->application->make('Flarum\Install\Prerequisites\Prerequisite');
}
protected function showErrors($errors)
{
foreach ($errors as $error) {
$this->info($error['message']);
if (isset($error['detail'])) {
$this->output->writeln('<comment>' . $error['detail'] . '</comment>');
}
}
}
}

View File

@ -17,7 +17,7 @@ class PhpExtensions extends AbstractPrerequisite
foreach (['mbstring', 'pdo_mysql', 'openssl', 'json', 'gd', 'dom', 'fileinfo'] as $extension) {
if (! extension_loaded($extension)) {
$this->errors[] = [
'message' => "The <strong>$extension</strong> extension is required.",
'message' => "The $extension extension is required.",
];
}
}

View File

@ -16,7 +16,7 @@ class PhpVersion extends AbstractPrerequisite
{
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
$this->errors[] = [
'message' => '<strong>PHP 5.5+</strong> is required.',
'message' => 'PHP 5.5+ is required.',
'detail' => 'You are running version '.PHP_VERSION.'. Talk to your hosting provider about upgrading to the latest PHP version.'
];
}

View File

@ -24,7 +24,7 @@ class WritablePaths extends AbstractPrerequisite
foreach ($paths as $path) {
if (! is_writable($path)) {
$this->errors[] = [
'message' => 'The <strong>'.realpath($path).'</strong> directory is not writable.',
'message' => 'The '.realpath($path).' directory is not writable.',
'detail' => 'Please chmod this directory'.($path !== public_path() ? ' and its contents' : '').' to 0775.'
];
}