-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.php
60 lines (50 loc) · 2.4 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
55
56
57
58
59
60
<?php
// {}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
// {} {}
// {} ___ _ _ ___ ___ ___ _ ____ {}
// {} / __| | | / __|_ _| | __| _ __ _ _ __ _____ __ _____ _ _| |__ __ _|__ / {}
// {} | (_ | |_| \__ \| | | _| '_/ _` | ' \/ -_) V V / _ \ '_| / / \ V /|_ \ {}
// {} \___|\___/|___/___| |_||_| \__,_|_|_|_\___|\_/\_/\___/_| |_\_\ \_/|___/ {}
// {} {}
// {} {}
// {} By Expringsoft {}
// {} {}
// {}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}{}
// Autoload classes
spl_autoload_register(function ($class) {
// project-specific namespace prefix
$prefix = 'App\\';
// base directory for the namespace prefix
$base_dir = __DIR__ . '/App/';
// does the class use the namespace prefix?
$len = strlen($prefix);
if (strncmp($prefix, $class, $len) !== 0) {
// no, move to the next registered autoloader
return;
}
// get the relative class name
$relative_class = substr($class, $len);
// replace the namespace prefix with the base directory, replace namespace
// separators with directory separators in the relative class name, append
// with .php
$file = $base_dir . str_replace('\\', DIRECTORY_SEPARATOR, $relative_class) . '.php';
// if the file exists, require it
if (file_exists($file)) {
require $file;
}
});
use App\Core\Application\App;
use App\Core\Server\Actions;
use App\Core\Server\Logger;
/**
* This code snippet initializes the application by creating a new instance of the App class.
* If an exception is thrown during the initialization process, it is caught and logged using the Logger class.
* An error response with a status code of 500 is then rendered, and the script execution is terminated.
*/
try {
new App();
} catch (\Throwable $th) {
Logger::LogError("App Launcher", $th->getMessage() . "\n" . $th->getTraceAsString(), $th->getCode(), $th->getPrevious());
Actions::renderError(500);
die();
}