-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
31 lines (23 loc) · 868 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
<?php
use Services\Router;
// Enable error reporting for debugging purposes.
error_reporting(E_ALL);
ini_set('display_errors', 'on');
// Autoload classes based on a 1:1 mapping from namespace to directory structure.
spl_autoload_register(function ($classPath) {
// Make sure the class path has the correct directory separator.
$classPath = str_replace('\\', DIRECTORY_SEPARATOR, $classPath);
$file = __DIR__ . DIRECTORY_SEPARATOR . $classPath . ".php";
if (is_readable($file)) {
require_once $file;
}
});
$uri = str_replace('/PanteaPHP', '', $_SERVER['REQUEST_URI']);
// Initialize the router and parse the URI. When an error occurs, show it to the visitor.
$router = new Router();
try {
$router->parse($uri);
}
catch (\Exception $error) {
var_dump($error->getMessage() . ' in file ' . $error->getFile() . ' on line ' . $error->getLine());
}