-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.php
37 lines (31 loc) · 921 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
32
33
34
35
36
37
<?php
session_start();
//require all PHP files from a directory
$folderList = array(
'./config/',
'./app/core/',
'./lib/',
);
foreach ($folderList as $folder) {
foreach (glob($folder . "*.php") as $filename) {
require $filename;
}
}
require './app/models/BaseModel.php';
spl_autoload_register(function ($className) {
require './app/controllers/' . $className . '.php';
});
//Controller
if (isset($_REQUEST['controller']) && '' != $_REQUEST['controller']) {
$controllerParam = strtolower($_REQUEST['controller']);
}
$controllerName = ucfirst(($controllerParam ?? '') . 'Controller');
require "./app/controllers/${controllerName}.php";
//Action
if (isset($_REQUEST['action']) && '' != $_REQUEST['action']) {
$actionParam = strtolower($_REQUEST['action']);
}
$actionName = $actionParam ?? 'index';
//Run
$controllerObject = new $controllerName;
$controllerObject->$actionName();