Az router használata saját MVC keretrendszerben

Emlékezzünk vissza a index.php fájl jelenlegi tartalmára:

index.php<?php
  namespace Core;
  
  error_reporting(E_ALL);
  ini_set('display_errors', 'on');
  
  spl_autoload_register(function($class) {
    // az Ön autoload megvalósítása
  });
  
  $routes = require $_SERVER['DOCUMENT_ROOT'] . '/project/config/routes.php';
?>

Mostantól a index.php fájlban a routerünket a következőképpen akarjuk használni:

index.php<?php
  $router = new Router();
  $track  = $router->getTrack($routes, $_SERVER['REQUEST_URI']);
?>

Átírhatjuk tömörebben is:

index.php<?php
  $track = ( new Router ) -> getTrack($routes, $_SERVER['REQUEST_URI']);
?>