Esempio n. 1
0
 public function testUrlBugIndexPHP()
 {
     $_SERVER['REQUEST_URI'] = '/arg1';
     $_SERVER['PHP_SELF'] = '/index.php/arg1';
     $router = new Router();
     $router->route('test', '/:arg1', function () {
         return 'rootRouteGet';
     });
     $result = $router->url('test', 'arg1');
     $this->assertEquals($result, '/arg1');
 }
Esempio n. 2
0
<?php

use router\Router;
include __DIR__ . '/../vendor/autoload.php';
$router = new Router();
$comment = '';
$router->route('root', '/', function () use(&$comment) {
    return $comment . 'Root';
})->route('args', '/:arg1', function ($arg1) use(&$comment) {
    return $comment . 'route with argument "' . $arg1 . '"';
});
$comment = '<h2>Routes</h2>
<ul>
    <li><a href="' . $router->url('root') . '">root</a></li>
    <li><a href="' . $router->url('args', 'arg1') . '">/:arg1</a> <a href="' . $router->url('args', 'arg2') . '">/:arg1</a></li>
</ul>
<hr />';
echo $router->match($_SERVER['REQUEST_URI']);