Using a Router in Your Own MVC Framework
Let's recall the current contents of the file index.php:
<?php
namespace Core;
error_reporting(E_ALL);
ini_set('display_errors', 'on');
spl_autoload_register(function($class) {
// your autoload implementation
});
$routes = require $_SERVER['DOCUMENT_ROOT'] . '/project/config/routes.php';
?>
Now, let's say we want to use our router
further in index.php
in the following way:
<?php
$router = new Router();
$track = $router->getTrack($routes, $_SERVER['REQUEST_URI']);
?>
It can be rewritten more compactly:
<?php
$track = ( new Router ) -> getTrack($routes, $_SERVER['REQUEST_URI']);
?>