1
1
Fork 0
mirror of https://github.com/openvk/chandler.git synced 2025-04-02 14:33:59 +03:00

Reformat the Configuration Loading Method

Closes .
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
debug: true websiteUrl: null
websiteUrl: null rootApp: "root"
rootApp: "root"
preferences:
preferences: appendExtension: "xhtml"
appendExtension: "xhtml" adminUrl: "/chandlerd"
adminUrl: "/chandlerd" exposeChandler: true
exposeChandler: true
extensions:
extensions: path: null
path: null allEnabled: false
allEnabled: false
database:
database: dsn: "mysql:host=localhost;dbname=db"
dsn: "mysql:host=localhost;dbname=db" user: "root"
user: "root" password: "root"
password: "root"
security:
security: secret: ""
secret: "" csrfProtection: "permissive"
csrfProtection: "permissive" extendedValidation: false
extendedValidation: false sessionDuration: 14
sessionDuration: 14

View file

@ -4,9 +4,6 @@ declare(strict_types = 1);
use Tracy\Debugger; 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. * Bootstrap class, that is called during framework starting phase.
* Initializes everything. * Initializes everything.
@ -27,29 +24,6 @@ class Bootstrap
Chandler\Extensions\ExtensionManager::getInstance(); 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. * Starts Tracy debugger session and installs panels.
* *

View file

@ -4,6 +4,9 @@ declare(strict_types = 1);
require_once(dirname(__DIR__) . "/vendor/autoload.php"); 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 = require("../chandler/Bootstrap.php");
$bootstrap->ignite(); $bootstrap->ignite();