|
@@ -3,7 +3,7 @@ discard block |
|
|
block discarded – undo |
|
3
|
3
|
/** |
|
4
|
4
|
* Loading composer Libraries |
|
5
|
5
|
*/ |
|
6
|
|
-require __DIR__ . '/../vendor/autoload.php'; |
|
|
6
|
+require __DIR__.'/../vendor/autoload.php'; |
|
7
|
7
|
|
|
8
|
8
|
|
|
9
|
9
|
/** |
|
@@ -23,14 +23,14 @@ discard block |
|
|
block discarded – undo |
|
23
|
23
|
*/ |
|
24
|
24
|
require __DIR__.'/../helpers.php'; |
|
25
|
25
|
|
|
26
|
|
-require __DIR__.'/../'.getenv('CONTROLLERS_DIRECTORY','controllers').'/Controller.php'; |
|
27
|
|
-$paths = array(__DIR__ . '/../'.getenv('VIEWS_DIRECTORY','views')); |
|
28
|
|
-$cache_path = array('cache_path' => __DIR__ . '/../'.getenv('CACHE_DIRECTORY','cache')); |
|
|
26
|
+require __DIR__.'/../'.getenv('CONTROLLERS_DIRECTORY', 'controllers').'/Controller.php'; |
|
|
27
|
+$paths = array(__DIR__.'/../'.getenv('VIEWS_DIRECTORY', 'views')); |
|
|
28
|
+$cache_path = array('cache_path' => __DIR__.'/../'.getenv('CACHE_DIRECTORY', 'cache')); |
|
29
|
29
|
|
|
30
|
30
|
$path = explode('/', trim(strtolower($_SERVER['REQUEST_URI']), '/')); |
|
31
|
|
-$path[count($path)-1] = explode('?', end($path))[0];// Removing get parameters from the Request URL |
|
|
31
|
+$path[count($path)-1] = explode('?', end($path))[0]; // Removing get parameters from the Request URL |
|
32
|
32
|
|
|
33
|
|
-$default_pages = ['index','home','default']; //Default pages of the website |
|
|
33
|
+$default_pages = ['index', 'home', 'default']; //Default pages of the website |
|
34
|
34
|
|
|
35
|
35
|
if (empty($path[0]) || in_array($path[0], $default_pages)) { |
|
36
|
36
|
$method = 'index'; // Loading default index method from the controller for homepage |
|
@@ -39,7 +39,7 @@ discard block |
|
|
block discarded – undo |
|
39
|
39
|
} |
|
40
|
40
|
|
|
41
|
41
|
$controller = new Controller($paths, $cache_path); |
|
42
|
|
-if (method_exists ($controller, $method)) { |
|
|
42
|
+if (method_exists($controller, $method)) { |
|
43
|
43
|
echo $controller->{ $method }(); // Calling the method from the Controller |
|
44
|
44
|
} else { |
|
45
|
45
|
echo $controller->notFound(); // Calling 404 Page if method not found |