Allow multiple config locations

This commit is contained in:
Alma Armas 2021-01-27 18:53:14 +00:00
parent 8aa46425b5
commit d0123f79db
1 changed files with 11 additions and 1 deletions

View File

@ -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();