-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
54 lines (41 loc) · 1.19 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
// Set the session timeout
ini_set('session.gc_maxlifetime', 14400); // 240 hourse
// Set the session cookie lifetime
ini_set('session.cookie_lifetime', 14400); // 240 hourse
session_start();
// Autoload classes
spl_autoload_register(function ($class) {
$prefix = 'App\\';
$base_dir = __DIR__ . '/app/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
if (file_exists($file)) {
require $file;
}
});
// Autoload core classes
spl_autoload_register(function ($class) {
$prefix = 'Core\\';
$base_dir = __DIR__ . '/core/';
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
return;
}
$relative_class = substr($class, $len);
$file = $base_dir . str_replace('\\', '/', $relative_class) . '.php';
if (file_exists($file)) {
require $file;
}
});
$router = new Core\Router();
require 'routes/web.php';
$url = $_SERVER['REQUEST_URI'];
$router->dispatch($url);