-
Notifications
You must be signed in to change notification settings - Fork 0
/
router.php
43 lines (35 loc) · 1.19 KB
/
router.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
<?php
/**
* _ __
* ___ ____ ___ ___ _________ _(_) /____
* / _ \/ __ `__ \/ _ \/ ___/ __ `/ / / ___/
* / __/ / / / / / __/ / / /_/ / / (__ )
* \___/_/ /_/ /_/\___/_/ \__,_/_/_/____/
*
* (c) Claudio Procida 2008-2024
*
* @format
*/
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/include/common.inc.php';
require_once __DIR__ . '/helpers/application_helper.php';
use Emeraldion\EmeRails\Config;
use Emeraldion\EmeRails\Helpers\ApplicationHelper;
use Emeraldion\EmeRails\Helpers\HTTP;
error_reporting(E_ALL);
if (isset($_REQUEST['controller']) && !empty($_REQUEST['controller'])) {
$main_controller_class =
'Emeraldion\\EmeRails\\Controllers\\' . joined_lower_to_camel_case($_REQUEST['controller']) . 'Controller';
if (!class_exists($main_controller_class)) {
HTTP::error(404);
}
// Instantiate main controller
$main_controller = new $main_controller_class();
// Set main controller's base path
$main_controller->set_base_path(__DIR__);
// Request rendering of the page
// (If action didn't already do it before)
$main_controller->render_page();
} else {
HTTP::error(500);
}