Fix errors in the router
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user