Korišćenje rutera u vašem vlastitom MVC okviru

Prisetimo se trenutnog sadržaja fajla index.php:

index.php<?php
  namespace Core;
  
  error_reporting(E_ALL);
  ini_set('display_errors', 'on');
  
  spl_autoload_register(function($class) {
    // vaša implementacija automatskog učitavanja
  });
  
  $routes = require $_SERVER['DOCUMENT_ROOT'] . '/project/config/routes.php';
?>

Sada, recimo da želimo da koristimo naš ruter dalje u index.php na sledeći način:

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

Ovo se može prepisati kompaktnije:

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