示例#1
0
 private function _getRouterWithRoutes()
 {
     $router = new FWRouter();
     $router->connect('/:test');
     $router->connect('/2/:test2', array('a' => 'aval', 'b' => 'bval'));
     $router->connect('/3/:test', array(), array('test' => '|^[a-z]+$|'));
     return $router;
 }
示例#2
0
 public static function getInstance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#3
0
文件: route.php 项目: apeschar/php-fw
<?php

// php version
if (version_compare(PHP_VERSION, '<', '5.2.3')) {
    die('[fw] PHP >= 5.2.3 required.');
}
// check constants
if (!defined('FW_DIR')) {
    die('[fw] FW_DIR not defined.');
}
if (!is_file(FW_DIR . '/route.php')) {
    die('[fw] FW_DIR incorrect.');
}
// load framework
require FW_DIR . '/load.php';
// create router
$router = new FWRouter();
$router->setBaseURL('/');
$router->loadYAMLFile(APP_DIR . '/conf/routes.yml');
if (is_file(APP_DIR . '/conf/routes.conf')) {
    $router->loadConfFile(APP_DIR . '/conf/routes.conf');
}
FWContext::setRouter($router);
// dispatch request
$request = new FWRequest();
$request->setRouter($router);
$request->dispatch(isset($_SERVER['PATH_INFO']) ? $_SERVER['PATH_INFO'] : '');