This repository has been archived by the owner on Feb 20, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
87 lines (73 loc) · 2.26 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
namespace App\System;
use App\System\ConfigLoader;
use App\System\Controller;
use App\System\Session;
use App\System\Router;
use App\System\LibrariesLoader;
use \Exception;
function requireFile(string $file) {
require_once(__DIR__ . '/' . $file . '.php');
}
function loadFile(string $path, string $file, string $type) {
$loaded = false;
$filePath = $path . $file;
$path = __DIR__ . '/' . $filePath . '.php';
try {
if(file_exists($path)) {
requireFile($filePath);
$loaded = true;
} else {
throw new Exception("File not found.");
}
} catch(Exception $e) {
error("Failed to load $type \"$file\" (path: $path)");
}
return $loaded;
}
// Loading requirements
$required = [
'system/router',
'system/session',
'system/configLoader',
'system/controller',
'system/utilities',
'system/blade',
'system/model',
'system/librariesLoader',
'system/paragonie/corner/CornerTrait',
'system/paragonie/corner/CornerInterface',
'system/paragonie/corner/Error',
'system/paragonie/corner/Exception',
'system/paragonie/easydb/EasyDB',
'system/paragonie/easydb/EasyStatement',
'system/paragonie/easydb/Factory',
'system/paragonie/easydb/Exception/ExceptionInterface',
'system/paragonie/easydb/Exception/ConstructorFailed',
'system/paragonie/easydb/Exception/InvalidIdentifier',
'system/paragonie/easydb/Exception/InvalidTableName',
'system/paragonie/easydb/Exception/MustBeArrayOrEasyStatement',
'system/paragonie/easydb/Exception/MustBeOneDimensionalArray',
'system/paragonie/easydb/Exception/QueryError'
];
foreach($required as $file) {
requireFile($file);
}
// Defining working directory
ConfigLoader::setWD(__DIR__);
Controller::setWD(__DIR__);
$cnf = new ConfigLoader();
// Loading libraries
$libraries = $cnf->load('libraries');
$lib_dir = $cnf->load('directories')['libraries'] . '/';
foreach($libraries as $lib) {
LibrariesLoader::load($lib);
}
// Loading helpers
$helpers = $cnf->load('helpers');
$help_dir = $cnf->load('directories')['helpers'] . '/';
foreach($helpers as $file_h) {
loadFile($help_dir, $file_h, 'helper');
}
Session::start();
Router::route(__DIR__);