|
|
@@ -6,13 +6,22 @@
|
|
|
require_once __DIR__ . "/autoloader.php";
|
|
|
AutoLoader::registerLoader();
|
|
|
|
|
|
+// Build a registry of routes by scanning the "routes" directory and loading all the files in there.
|
|
|
Router::scan("routes/*.php");
|
|
|
+
|
|
|
+// Now, we try to find the route that matches the given request URI (actually _path_) and HTTP method.
|
|
|
$route = Router::findRoute($_SERVER["REQUEST_URI"], $_SERVER["REQUEST_METHOD"]);
|
|
|
|
|
|
+// We do some more output buffering in order to avoid problems with setting
|
|
|
+// the HTTP status code or headers too late
|
|
|
ob_start();
|
|
|
+
|
|
|
+// This down here can be useful for debugging ;)
|
|
|
//var_dump($route);
|
|
|
|
|
|
+// Just execute the route ...
|
|
|
$route->execute();
|
|
|
-$output = ob_get_clean();
|
|
|
|
|
|
+// ... and print the result
|
|
|
+$output = ob_get_clean();
|
|
|
print($output);
|