corso https://vola.udemy.com/course/php-mvc-from-scratch/learn/lecture/40931984#overview
filippo.bertilotti
2024-05-10 f6df29226eaad3c37245b8774de6639acf589b1d
index.php
@@ -8,23 +8,15 @@
$segments = explode("/", $path);
$router = new Framework\Router;
$router->add("/product/{slug:[\w-]+}", ["controller" => "products", "action" => "show"]);
$router->add("/{controller}/{id:\d+}/{action}");
$router->add("/home/index", ["controller" => "home", "action" => "index"]);
$router->add("/products", ["controller" => "products", "action" => "index"]);
$router->add("/", ["controller" => "home", "action" => "index"]);
$router->add("/{controller}/{action}");
$dispatcher = new Framework\Dispatcher($router);
$params = $router->match($path);
if($params === false) {
    exit("No routes matched");
}
$controller = $params["controller"];
$action = $params["action"];
require "src/controllers/$controller.php";
$controller_object = new $controller;
$controller_object->$action();
$dispatcher->handle($path);