From d0123f79db5d26d3b439cedfedfdb2606be96688 Mon Sep 17 00:00:00 2001 From: Alma Armas Date: Wed, 27 Jan 2021 18:53:14 +0000 Subject: [PATCH] Allow multiple config locations --- chandler/Bootstrap.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/chandler/Bootstrap.php b/chandler/Bootstrap.php index 7c93552..7f7a58d 100644 --- a/chandler/Bootstrap.php +++ b/chandler/Bootstrap.php @@ -4,7 +4,6 @@ use Tracy\Debugger; define("CHANDLER_VER", "0.0.1", false); define("CHANDLER_ROOT", dirname(__FILE__) . "/..", false); -define("CHANDLER_ROOT_CONF", yaml_parse_file(CHANDLER_ROOT . "/chandler.yml")["chandler"]); /** * Bootstrap class, that is called during framework starting phase. @@ -27,6 +26,16 @@ class Bootstrap Debugger::getBar()->addPanel(new Chandler\Debug\DatabasePanel); } + private function loadConfig(): void + { + if(!file_exists($conf = CHANDLER_ROOT . "/chandler.yml")) + if(!file_exists($conf = CHANDLER_ROOT . "/../chandler.yml")) + if(!file_exists($conf = "/etc/chandler.d/chandler.yml")) + exit("Configuration file not found... Have you forgotten to rename it?"); + + define("CHANDLER_ROOT_CONF", chandler_parse_yaml($conf)["chandler"]); + } + /** * Loads procedural APIs. * @@ -128,6 +137,7 @@ class Bootstrap { $this->registerFunctions(); $this->registerAutoloaders(); + $this->loadConfig(); $this->registerDebugger(); $this->igniteExtensions();