1 <?php declare(strict_types=1);
3 namespace Cli\Services;
7 class RequirementsValidator
10 * Ensure the required PHP extensions are installed for this command.
13 public static function validate(): void
17 if (version_compare(PHP_VERSION, '8.0.2') < 0) {
18 $errors[] = "PHP >= 8.0.2 is required to install BookStack.";
21 $requiredExtensions = ['curl', 'gd', 'iconv', 'libxml', 'mbstring', 'mysqlnd', 'xml'];
22 foreach ($requiredExtensions as $extension) {
23 if (!extension_loaded($extension)) {
24 $errors[] = "The \"{$extension}\" PHP extension is required by not active.";
29 (new ProgramRunner('git', '/usr/bin/git'))->ensureFound();
30 (new ProgramRunner('php', '/usr/bin/php'))->ensureFound();
31 } catch (Exception $exception) {
32 $errors[] = $exception->getMessage();
35 if (count($errors) > 0) {
36 throw new Exception("Requirements failed with following errors:\n" . implode("\n", $errors));