-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
35 lines (27 loc) · 850 Bytes
/
index.php
File metadata and controls
35 lines (27 loc) · 850 Bytes
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
<?php
declare(strict_types=1);
spl_autoload_register(function ($class) {
//TODO: dorobić sprawdzanie czy plik istnieje
$pathToClass = str_replace(["\\", 'App/'], ["/", ""], $class);
include __DIR__.'/src/' . $pathToClass . '.php';
});
require_once('src/Utils/debug.php');
$configuration = require_once('config/config.php');
use App\Controller\Controller;
use App\Request;
use App\Exception\AppException;
use App\Exception\StorageException;
try {
Controller::initConfiguration($configuration);
(new Controller(
new Request($_GET, $_POST, $_SERVER)
))->run();
} catch (AppException | StorageException $e) {
echo "<h2>{$e->getMessage()}</h2>";
} catch (\Throwable $e) {
echo '<h2>Global application error</h2>';
} finally {
if (defined('ENV') && ENV === 'dev' && isset($e)) {
dd($e);
}
}