Ejemplo n.º 1
0
 public function testCLI2()
 {
     unset($_SERVER['SERVER_PROTOCOL']);
     $_SERVER['argv'] = array('index.php', '-m', 'hello', '-a', 'world');
     $router = new LtRouter();
     $router->init();
     $this->assertEquals('hello', $router->module);
     $this->assertEquals('world', $router->action);
     $this->assertEquals(array('m' => 'hello', 'a' => 'world'), $_GET);
 }
Ejemplo n.º 2
0
include $lotusHome . "runtime/Config.php";
include $lotusHome . "runtime/Store.php";
include $lotusHome . "runtime/StoreMemory.php";
include $lotusHome . "runtime/Router/Router.php";
include $lotusHome . "runtime/Url/Url.php";
// 默认的module和action的名字
$config['router.routing_table']['default'] = array('module' => 'default', 'action' => 'index');
// URL中变量的分隔符号
//$config['router.routing_table']['delimiter'] = '-';
// 后缀,常用来将URL模拟成单个文件
//$config['router.routing_table']['postfix'] = '.html';
// REWRITE STANDARD PATH_INFO 三种模式,不分大小写
$config['router.routing_table']['protocol'] = 'REWRITE';
$configHandle = new LtConfig();
$configHandle->addConfig($config);
$router = new LtRouter();
$router->configHandle = $configHandle;
$router->init();
$url = new LtUrl();
$url->configHandle = $configHandle;
$url->init();
$params = array('id' => 123456, 'page' => '12', 'q-/key' => '空 -/格');
$url->baseUrl = 'http://127.0.0.1';
$link1 = $url->generate('news', 'top');
$url->baseUrl = 'http://localhost';
$link2 = $url->generate('goods', 'detail', $params);
$url->baseUrl = 'http://127.0.0.1';
$link3 = $url->getLink('goods', 'detail', $params);
$url2 = new LtUrl();
// $url2->withPath = false; //是否包含相对路径
$url2->init();