-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.php
More file actions
37 lines (30 loc) · 911 Bytes
/
index.php
File metadata and controls
37 lines (30 loc) · 911 Bytes
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
require_once 'app/components/Autoloader.php';
require_once 'vendor/autoload.php';
use app\components\Session;
use app\controllers\MainController;
use app\components\Autoloader;
define('PROJECT_NAME', 'SkillUP');
define('ROOT_DIR', __DIR__);
define('SEPARATOR', '\\');
Autoloader::register();
Session::start();
$query = $_GET;
$method = null;
$action = null;
if (isset($query['act'])) {
$action = $query['act'];
$method = $action.'Action';
}
foreach (glob('app/controllers/[^ ]*Controller.php') as $controllerPath) {
$controllerPath = SEPARATOR.str_replace(['.php', '/'], ['', SEPARATOR], $controllerPath);
// Метод точно есть
if ($method && method_exists($controllerPath, $method)) {
$controller = new $controllerPath($action);
$controller->{$method}();
break;
}
}
if (!isset($controller)) {
(new MainController())->homeAction();
}