Fix errors in the router

This commit is contained in:
2017-09-04 11:02:25 +07:00
parent 128d337383
commit bfdd632adf
4 changed files with 21 additions and 8 deletions

View File

@@ -1,9 +1,19 @@
<?php
$router = new Router();
spl_autoload_register(function($class)
{
$root = dirname(__DIR__);
if(is_readable($file = $root . '/' . str_replace('\\', '/', $class) . '.php'))
{
require $file;
}
});
$router->add('', ['controller' => 'Data', 'action' => 'index']);
$router = new Core\Router();
$router->add('', ['controller' => 'posts', 'action' => 'index']);
$router->add('{controller}/{action}');
$router->add('{controller}/{action}/{id:\d+}');
$router->add('{action}', ['controller' => 'home']);
$url = $_SERVER['QUERY_STRING'];
$url = $_SERVER['REQUEST_URI'];
$router->dispatch($url);