-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
32 lines (28 loc) · 989 Bytes
/
index.php
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
<?php
require __DIR__ . '/vendor/autoload.php';
spl_autoload_register(function ($class) {
$decomposed = explode('\\', $class);
if (count($decomposed) > 1 && $decomposed[0] === 'uCMS') {
$decomposed[0] = 'app'; // all our classes are in app dir
$fullPath = __DIR__ . '/' . implode('/', $decomposed) . '.php';
if (!is_file($fullPath)) {
throw new Exception("Unable to autoload class $class.");
}
require_once __DIR__ . '/' . implode('/', $decomposed) . '.php';
}
});
try {
// In the first version, the config is loaded from exact file.
$config = uCMS\Config::loadYaml(__DIR__ . '/config/config.yaml');
} catch (Exception $e) {
http_response_code(500);
header('Content-Type: text/plain');
echo "Internal Error: Unable to load configuration file.\n";
exit;
}
try {
$app = new uCMS\App($config);
$app->execute($_SERVER['REQUEST_URI']);
} catch (Exception $e) {
$app->showErrorPage();
}