-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkernel.php
38 lines (35 loc) · 1.07 KB
/
kernel.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
<?php
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
include_once('config/database.php');
include_once('config/setup.php');
include_once('config/connection.php');
spl_autoload_register(function ($class_name) {
if (file_exists('./controller/' . $class_name . '.php')) {
include_once './controller/' . $class_name . '.php';
} else if (file_exists('./model/' . $class_name . '.php')) {
include_once './model/' . $class_name . '.php';
}
});
$db = Connection::connect($DB_DSN, $DB_NAME, $DB_USER, $DB_PASSWORD);
include_once('routes.php');
if(!empty($route)) {
$routes = explode('@', $route);
$controller = ucfirst($routes[0]);
$model = ucfirst(str_replace("Controller", "", $routes[0])) . "Model";
$action = lcfirst($routes[1]);
} else if ($_SERVER['REQUEST_URI'] === "/"){
$controller = "UserController";
$model = "UserModel";
$action = "showLogin";
} else {
$controller = "UserController";
$model = "UserModel";
$action = "notFound";
}
$loadNew = new $controller();
$model = new $model();
$loadNew->model=$model;
$model->db = $db;
$index = $loadNew->$action();