コード例 #1
0
ファイル: index.php プロジェクト: purdue-epics-wise/AMBI
<?php

// Twig
require_once './vendor/twig/twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
// Autoloader
spl_autoload_register(function ($class) {
    $root = '.';
    // root is current file
    $class_file = str_replace('\\', '/', $class);
    $file = "{$root}/{$class_file}.php";
    if (is_readable($file)) {
        require $file;
    }
});
// Error and Exception Handling
error_reporting(E_ALL);
set_error_handler('Core\\Error::errorHandler');
set_exception_handler('Core\\Error::exceptionHandler');
/**
 * Routing
 */
$router = new Core\Router();
$router->add('', ['controller' => 'Home', 'action' => 'index']);
$router->add('authenticate', ['controller' => 'Authenticate', 'action' => 'index']);
$router->add('diary', ['controller' => 'Diary', 'action' => 'index']);
$router->add('{controller}/{action}');
$router->add('admin/{controller}/{action}', ['namespace' => 'Admin']);
$router->dispatch($_SERVER['QUERY_STRING']);
コード例 #2
0
ファイル: index.php プロジェクト: Shareed2k/mvc_demo
<?php

/**
 * Composer autoloader
 *
 */
require_once '../vendor/autoload.php';
/**
 * Error and Exception handling
 *
 */
error_reporting(E_ALL);
set_error_handler('Core\\Error::errorHandler');
set_exception_handler('Core\\Error::exceptionHandler');
if (session_status() == PHP_SESSION_NONE) {
    session_start();
}
$router = new \Core\Router();
/**
 * Add the Route
 *
 */
$router->add('', ['controller' => 'HomeController', 'action' => 'index']);
$router->add('home', ['controller' => 'HomeController', 'action' => 'index']);
$router->add('home/fileupload', ['controller' => 'HomeController', 'action' => 'fileUpload']);
$router->add('contact', ['controller' => 'ContactController', 'action' => 'index']);
$router->add('admin/users/{id:\\d+}/index', ['controller' => 'UsersController', 'action' => 'index', 'namespace' => 'Admin']);
//$router->add('{controller}/{id:\d+}/{action}');
$url = $_SERVER['QUERY_STRING'];
$router->dispatch($url);