Fixes config code

main
Yasen Pramatarov 2025-04-24 14:30:35 +03:00
parent 13f2ca4fe4
commit ed1c305358
2 changed files with 17 additions and 0 deletions

View File

@ -4,6 +4,11 @@ namespace App\Core;
class ConfigLoader class ConfigLoader
{ {
/**
* @var string|null
*/
private static $configPath = null;
/** /**
* Load configuration array from a set of possible file locations. * Load configuration array from a set of possible file locations.
* *
@ -22,6 +27,15 @@ class ConfigLoader
if (!$configFile) { if (!$configFile) {
die('Config file not found'); die('Config file not found');
} }
self::$configPath = $configFile;
return require $configFile; return require $configFile;
} }
/**
* @return string|null
*/
public static function getConfigPath(): ?string
{
return self::$configPath;
}
} }

View File

@ -121,6 +121,9 @@ $config = ConfigLoader::loadConfig([
'/srv/jilo-web/jilo-web.conf.php', '/srv/jilo-web/jilo-web.conf.php',
'/opt/jilo-web/jilo-web.conf.php', '/opt/jilo-web/jilo-web.conf.php',
]); ]);
// Expose config file path for pages
$config_file = ConfigLoader::getConfigPath();
$localConfigPath = str_replace(__DIR__ . '/..', '', $config_file);
$app_root = $config['folder']; $app_root = $config['folder'];