summaryrefslogtreecommitdiff
path: root/public/index.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2022-03-06 00:48:14 +0100
committerDaniel Weipert <code@drogueronin.de>2022-03-06 00:48:14 +0100
commitb2a86c7df7d5a473e80034832a01b21444fa50e6 (patch)
tree2b18e08124ff3e8602a20ba27fef3ae4d066cc28 /public/index.php
parentdf428380e288db75b41ace5d6274f44916517f9f (diff)
Refactor
Diffstat (limited to 'public/index.php')
-rw-r--r--public/index.php21
1 files changed, 20 insertions, 1 deletions
diff --git a/public/index.php b/public/index.php
index b943298..8a7ec7d 100644
--- a/public/index.php
+++ b/public/index.php
@@ -1,11 +1,16 @@
<?php
use FlatFileForms\App;
+use FlatFileForms\PluginLoader;
+use FlatFileForms\PreLoader;
use Yosymfony\Toml\Toml;
require_once dirname(__DIR__) . '/vendor/autoload.php';
-function findAppConfigFile($path)
+/**
+ * Find the config file
+ */
+function findAppConfigFile(string $path): string
{
$currentDirectory = $path;
while ($currentDirectory !== '/') {
@@ -20,17 +25,31 @@ function findAppConfigFile($path)
die('config.toml missing');
}
+// find and parse config
$configFile = findAppConfigFile(dirname(__DIR__));
$config = Toml::parseFile($configFile);
+// prepare possibly relative folders path
chdir(dirname($configFile));
+
$contentDirectoryPath = realpath($config['app']['contentFolderPath']);
$contentDirectoryPath === false && die('Content folder "' . $config['app']['contentFolderPath'] . '" missing');
$config['app']['contentFolderPath'] = $contentDirectoryPath;
+
+$pluginsDirectoryPath = realpath($config['app']['pluginsFolderPath']);
+$pluginsDirectoryPath === false && die('Plugins folder "' . $config['app']['pluginsFolderPath'] . '" missing');
+$config['app']['pluginsFolderPath'] = $pluginsDirectoryPath;
+
chdir($_SERVER['DOCUMENT_ROOT']);
+// set config values to global $_ENV
foreach ($config as $key => $value) {
$_ENV[$key] = $value;
}
+// load
+new PreLoader();
+new PluginLoader();
+
+// run
new App();