From 88880f14dff2731838953b937692f87620750f69 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 27 Jan 2022 22:57:25 +0100 Subject: Add Kernel with config --- src/Kernel.php | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 src/Kernel.php (limited to 'src/Kernel.php') diff --git a/src/Kernel.php b/src/Kernel.php new file mode 100644 index 0000000..29785a8 --- /dev/null +++ b/src/Kernel.php @@ -0,0 +1,51 @@ + $value) { + self::$config[$key] = $value; + } + + Template::init(); + DB::init(); + new Router(); + } + + /** + * Find app config file in parent directories + */ + private static function findAppConfigFile(string $path): string + { + $currentDirectory = $path; + while ($currentDirectory !== '/') { + $configFile = $currentDirectory . '/config.php'; + if (file_exists($configFile)) { + return $configFile; + } + + $currentDirectory = dirname($currentDirectory); + } + + die('config.php missing'); + } + + /** + * Get config value + */ + public static function config($key): mixed + { + return self::$config[$key]; + } +} + -- cgit v1.2.3