diff --git a/src/Install/Console/InstallCommand.php b/src/Install/Console/InstallCommand.php
index 79bf253ad..ecb79b267 100644
--- a/src/Install/Console/InstallCommand.php
+++ b/src/Install/Console/InstallCommand.php
@@ -62,11 +62,22 @@ class InstallCommand extends Command
{
$this->init();
- $this->info('Installing Flarum...');
+ $prerequisites = $this->getPrerequisites();
+ $prerequisites->check();
+ $errors = $prerequisites->getErrors();
- $this->install();
+ if (empty($errors)) {
+ $this->info('Installing Flarum...');
- $this->info('DONE.');
+ $this->install();
+
+ $this->info('DONE.');
+ } else {
+ $this->output->writeln(
+ 'Please fix the following errors before we can continue with the installation.'
+ );
+ $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('' . $error['detail'] . '');
+ }
+ }
+ }
}
diff --git a/src/Install/Prerequisites/PhpExtensions.php b/src/Install/Prerequisites/PhpExtensions.php
index f4ff6b29c..117b21f37 100644
--- a/src/Install/Prerequisites/PhpExtensions.php
+++ b/src/Install/Prerequisites/PhpExtensions.php
@@ -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 $extension extension is required.",
+ 'message' => "The $extension extension is required.",
];
}
}
diff --git a/src/Install/Prerequisites/PhpVersion.php b/src/Install/Prerequisites/PhpVersion.php
index 4d6c2af3e..4199b78d8 100644
--- a/src/Install/Prerequisites/PhpVersion.php
+++ b/src/Install/Prerequisites/PhpVersion.php
@@ -16,7 +16,7 @@ class PhpVersion extends AbstractPrerequisite
{
if (version_compare(PHP_VERSION, '5.5.0', '<')) {
$this->errors[] = [
- 'message' => 'PHP 5.5+ 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.'
];
}
diff --git a/src/Install/Prerequisites/WritablePaths.php b/src/Install/Prerequisites/WritablePaths.php
index 6fcb37213..f9a614427 100644
--- a/src/Install/Prerequisites/WritablePaths.php
+++ b/src/Install/Prerequisites/WritablePaths.php
@@ -24,8 +24,8 @@ class WritablePaths extends AbstractPrerequisite
foreach ($paths as $path) {
if (! is_writable($path)) {
$this->errors[] = [
- 'message' => 'The '.realpath($path).' directory is not writable.',
- 'detail' => 'Please chmod this directory '.($path !== public_path() ? ' and its contents' : '').' to 0775.'
+ 'message' => 'The '.realpath($path).' directory is not writable.',
+ 'detail' => 'Please chmod this directory'.($path !== public_path() ? ' and its contents' : '').' to 0775.'
];
}
}