1 <?php declare(strict_types=1);
3 namespace Cli\Services;
7 class RequirementsValidator
9 protected static string $phpVersion = '8.0.2';
10 protected static array $extensions = [
27 * Ensure the required PHP extensions are installed for this command.
30 public static function validate(): void
34 if (version_compare(PHP_VERSION, static::$phpVersion) < 0) {
35 $errors[] = sprintf("PHP >= %s is required to install BookStack.", static::$phpVersion);
38 foreach (static::$extensions as $extension) {
39 if (!extension_loaded($extension)) {
40 $errors[] = "The \"{$extension}\" PHP extension is required but not active.";
45 (new ProgramRunner('git', '/usr/bin/git'))->ensureFound();
46 (new ProgramRunner('php', '/usr/bin/php'))->ensureFound();
47 } catch (Exception $exception) {
48 $errors[] = $exception->getMessage();
51 if (count($errors) > 0) {
52 throw new Exception("Requirements failed with following errors:\n" . implode("\n", $errors));