mirror of
https://github.com/grocy/grocy.git
synced 2026-04-05 20:36:15 +02:00
Added check if all dependencies are installed and config.php/config-dist.php exists
This commit is contained in:
parent
dcfd9d848d
commit
71b7a24462
38
helpers/PrerequisiteChecker.php
Normal file
38
helpers/PrerequisiteChecker.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
class ERequirementNotMet extends Exception {
|
||||
}
|
||||
|
||||
class PrerequisiteChecker {
|
||||
|
||||
public function checkRequirements() {
|
||||
self::checkForConfigFile();
|
||||
self::checkForConfigDistFile();
|
||||
self::checkForComposer();
|
||||
self::checkForYarn();
|
||||
}
|
||||
|
||||
|
||||
private function checkForConfigFile() {
|
||||
if (!file_exists(__DIR__ . "/../data/config.php"))
|
||||
throw new ERequirementNotMet("/data/config.php not found. Have you copied config-dist.php to the data directory and renamed it to config.php?");
|
||||
}
|
||||
|
||||
private function checkForConfigDistFile() {
|
||||
if (!file_exists(__DIR__ . "/../config-dist.php"))
|
||||
throw new ERequirementNotMet("config-dist.php not found. Please do not remove this file.");
|
||||
}
|
||||
|
||||
private function checkForComposer() {
|
||||
if (!file_exists(__DIR__ . "/../vendor/autoload.php"))
|
||||
throw new ERequirementNotMet("/vendor/autoload.php not found. Have you run Composer?");
|
||||
}
|
||||
|
||||
private function checkForYarn() {
|
||||
if (!file_exists(__DIR__ . "/../public/node_modules"))
|
||||
throw new ERequirementNotMet("/public/node_modules not found. Have you run Yarn?");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
@ -1,3 +1,13 @@
|
|||
<?php
|
||||
|
||||
require_once __DIR__ . '/../helpers/PrerequisiteChecker.php';
|
||||
|
||||
try {
|
||||
(new PrerequisiteChecker)->checkRequirements();
|
||||
} catch (ERequirementNotMet $e) {
|
||||
die("Unable to run grocy: " . $e->getMessage());
|
||||
}
|
||||
|
||||
require_once __DIR__ . '/../app.php';
|
||||
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user