summaryrefslogtreecommitdiff
path: root/public/index.php
diff options
context:
space:
mode:
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();