lepisi-pengumuman/public/index.php

20 lines
475 B
PHP

<?php
spl_autoload_register(function($class)
{
$root = dirname(__DIR__);
if(is_readable($file = $root . '/' . str_replace('\\', '/', $class) . '.php'))
{
require $file;
}
});
$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['REQUEST_URI'];
$router->dispatch($url);