diff --git a/config/routes.php b/config/routes.php index d399b9c..8026f7b 100644 --- a/config/routes.php +++ b/config/routes.php @@ -1,2 +1,4 @@ get('/', '/', [new HomeController(), 'home']); \ No newline at end of file +use src\Controller\HomeController; + +$router->get('/', [new HomeController(), 'index']); \ No newline at end of file diff --git a/public/index.php b/public/index.php index f08ff53..6d72079 100644 --- a/public/index.php +++ b/public/index.php @@ -1,6 +1,8 @@ addNamespace('src', __DIR__ . '/../src'); $autoloader->register(); diff --git a/src/Controller/BaseController.php b/src/Controller/BaseController.php index 391fd8e..167323a 100644 --- a/src/Controller/BaseController.php +++ b/src/Controller/BaseController.php @@ -1,11 +1,13 @@ routes['GET'][$path] = $handler; } @@ -17,7 +17,8 @@ public class Router public function dispatch(string $method, string $uri): void { - $handler = $this->routes[$method][$uri] ?? null; + $path = parse_url($uri, PHP_URL_PATH) ?? '/'; + $handler = $this->routes[$method][$path] ?? null; if ($handler === null) { http_response_code(404);