-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
35 lines (28 loc) · 890 Bytes
/
index.php
File metadata and controls
35 lines (28 loc) · 890 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
<?php
ini_set("display_errors", 1);
require 'route.php';
$requestUrl = $_SERVER['QUERY_STRING'];
$newRoute = new Route();
// Add the routes
$newRoute->add('', ['controller' => 'Home', 'action' => 'index']);
$newRoute->add('/projects', ['controller' => 'Projects', 'action' => 'index']);
$newRoute->add('/projects/new', ['controller' => 'Projects', 'action' => 'new']);
if ($newRoute->match($requestUrl)) {
$chkall = $newRoute->getParams();
if(file_exists("pages/".$chkall['controller'].".php")){
require "pages/".$chkall['controller'].".php";
$class_ = ucwords($chkall['controller']);
$controller = new $class_;
if($chkall['action'] == ""){
$controller->index();
}else{
$action_ = $chkall['action'];
$controller->$action_();
}
}else{
echo "No controller found named: ".$chkall['controller'];
}
}else{
echo "NOT FOUND";
}
?>