Compare commits
2 Commits
ed0baf18d3
...
c2f0fe6793
Author | SHA1 | Date |
---|---|---|
|
c2f0fe6793 | |
|
7dfbe49996 |
|
@ -0,0 +1,27 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Core;
|
||||||
|
|
||||||
|
class ConfigLoader
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Load configuration array from a set of possible file locations.
|
||||||
|
*
|
||||||
|
* @param string[] $locations
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public static function loadConfig(array $locations): array
|
||||||
|
{
|
||||||
|
$configFile = null;
|
||||||
|
foreach ($locations as $location) {
|
||||||
|
if (file_exists($location)) {
|
||||||
|
$configFile = $location;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!$configFile) {
|
||||||
|
die('Config file not found');
|
||||||
|
}
|
||||||
|
return require $configFile;
|
||||||
|
}
|
||||||
|
}
|
|
@ -111,29 +111,16 @@ $allowed_urls = [
|
||||||
// Let plugins filter/extend allowed_urls
|
// Let plugins filter/extend allowed_urls
|
||||||
$allowed_urls = filter_allowed_urls($allowed_urls);
|
$allowed_urls = filter_allowed_urls($allowed_urls);
|
||||||
|
|
||||||
// cnfig file
|
require_once __DIR__ . '/../app/core/ConfigLoader.php';
|
||||||
// possible locations, in order of preference
|
use App\Core\ConfigLoader;
|
||||||
$config_file_locations = [
|
|
||||||
|
// Load configuration
|
||||||
|
$config = ConfigLoader::loadConfig([
|
||||||
__DIR__ . '/../app/config/jilo-web.conf.php',
|
__DIR__ . '/../app/config/jilo-web.conf.php',
|
||||||
__DIR__ . '/../jilo-web.conf.php',
|
__DIR__ . '/../jilo-web.conf.php',
|
||||||
'/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',
|
||||||
];
|
]);
|
||||||
$config_file = null;
|
|
||||||
// try to find the config file
|
|
||||||
foreach ($config_file_locations as $location) {
|
|
||||||
if (file_exists($location)) {
|
|
||||||
$config_file = $location;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if found, use it
|
|
||||||
if ($config_file) {
|
|
||||||
$localConfigPath = str_replace(__DIR__ . '/..', '', $config_file);
|
|
||||||
$config = require $config_file;
|
|
||||||
} else {
|
|
||||||
die('Config file not found');
|
|
||||||
}
|
|
||||||
|
|
||||||
$app_root = $config['folder'];
|
$app_root = $config['folder'];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue