Reformat the Configuration Loading Method

Closes #12.
This commit is contained in:
Ilya Bakhlin 2022-01-01 19:28:47 +01:00
parent b457218e26
commit 4188fbba67
3 changed files with 26 additions and 50 deletions

View file

@ -1,24 +1,23 @@
chandler:
debug: true
websiteUrl: null
rootApp: "root"
preferences:
appendExtension: "xhtml"
adminUrl: "/chandlerd"
exposeChandler: true
extensions:
path: null
allEnabled: false
database:
dsn: "mysql:host=localhost;dbname=db"
user: "root"
password: "root"
security:
secret: ""
csrfProtection: "permissive"
extendedValidation: false
sessionDuration: 14
debug: true
websiteUrl: null
rootApp: "root"
preferences:
appendExtension: "xhtml"
adminUrl: "/chandlerd"
exposeChandler: true
extensions:
path: null
allEnabled: false
database:
dsn: "mysql:host=localhost;dbname=db"
user: "root"
password: "root"
security:
secret: ""
csrfProtection: "permissive"
extendedValidation: false
sessionDuration: 14

View file

@ -4,9 +4,6 @@ declare(strict_types = 1);
use Tracy\Debugger;
define("CHANDLER_VER", "0.0.1", false); // IMPROVE: Remove this.
define("CHANDLER_ROOT", dirname(__FILE__) . "/..", false); // IMPROVE: Remove this.
/**
* Bootstrap class, that is called during framework starting phase.
* Initializes everything.
@ -27,29 +24,6 @@ class Bootstrap
Chandler\Extensions\ExtensionManager::getInstance();
}
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"]);
}
/**
* Set ups autoloaders.
*
* @return void
* @internal
*/
private function registerAutoloaders(): void
{
spl_autoload_register(function ($class): void {
if (strpos($class, "Chandler\\") !== 0) return;
require_once(str_replace("\\", "/", str_replace("Chandler\\", CHANDLER_ROOT . "/chandler/", $class)) . ".php");
}, true, true);
}
/**
* Starts Tracy debugger session and installs panels.
*

View file

@ -4,6 +4,9 @@ declare(strict_types = 1);
require_once(dirname(__DIR__) . "/vendor/autoload.php");
define("CHANDLER_ROOT", dirname(__DIR__));
define("CHANDLER_ROOT_CONF", yaml_parse_file(CHANDLER_ROOT . "/chandler.yml"));
$bootstrap = require("../chandler/Bootstrap.php");
$bootstrap->ignite();