Ich möchte eine Art Flask Router in PHP erstellen.
$requestURI = $_SERVER['REQUEST_URI'];
$routes = [
    '/' => 'HomeController@index',
    '/about' => 'AboutController@index',
    '/contact' => 'ContactController@index'
];
if (array_key_exists($requestURI, $routes)) {
    $controllerAction = $routes[$requestURI];
    
    $data = explode('@', $controllerAction);
    
    echo $data[0] . " -> " . $data[1];
} else {
    echo "404 - Seite nicht gefunden";
}
?>Jetzt habe ich aber ein Problem. Wie kann ich die Routen
/posts/YYYY/
/posts/YYYY/MM/
/posts/YYYY/MM/DD
/posts/YYYY/MM/DD/POSTNAME
unterscheiden? Die Zahlen sind ja dynamisch, muss ich für jeden Fall eine Route bilden?