summaryrefslogtreecommitdiff
path: root/public/index.php
blob: b7895e7f18ce5116f6861194ee57a79ec58f6d2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php

use FlatFileForms\App;
use Yosymfony\Toml\Toml;

require_once dirname(__DIR__) . '/vendor/autoload.php';

function findAppConfigFile($path)
{
  $currentFolder = $path;
  while ($currentFolder !== '/') {
    $configFile = $currentFolder . '/config.toml';
    if (file_exists($configFile)) {
      return $configFile;
    }

    $currentFolder = dirname($currentFolder);
  }

  die('config.toml missing');
}

$configFile = findAppConfigFile(dirname(__DIR__));
$config = Toml::parseFile($configFile);

chdir(dirname($configFile));
$contentFolderPath = realpath($config['app']['contentFolderPath']);
$contentFolderPath === false && die('Content folder "' . $config['app']['contentFolderPath'] . '" missing');
$config['app']['contentFolderPath'] = $contentFolderPath;
chdir($_SERVER['DOCUMENT_ROOT']);

foreach ($config as $key => $value) {
  $_ENV[$key] = $value;
}

new App();