auraphp/Aura.Router — Issue #6: In readme
Author: harikt
Created: 2012-01-07 17:28:12+00:00
State: open

In the advanced section

`method -- The $server['REQUEST_METHOD'] must match one of these values.`
`secure -- When true the $server['HTTPS'] ` ,

I feel its $_SERVER , but as I am confused whether you was trying to represent the variable in signature function over

`is_match -- A custom callback or closure with the signature function(array $server, \ArrayObject $matches)`

Sample code I tried is not working , confusion over the `format` in documentation . See first example no dot for format , second one has dot for the format . I feel we don't need the dot to be passed . Do you feel so ? Then why ? Normally we say html , atom like so , not .html , .xml etc .

add('Aura\Router', $package_dir . '/Aura.Router/src/' );
$loader->register();
use Aura\Router\Map;
use Aura\Router\RouteFactory;
$map = new Map(new RouteFactory);
/*
$map->add('home', '/');
$map->add(null, '/{:controller}/{:action}/{:id}');
$map->add('read', '/blog/read/{:id}{:format}', [
'params' => [
'id' => '(\d+)',
'format' => '(\..+)?',
],
'values' => [
'controller' => 'blog',
'action' => 'read',
'format' => '.html',
]
]);
*/
$map->add('read', '/blog/read/{:id}{:format}', [
'params' => [
'id' => '(\d+)',
'format' => '(\..+)?',
],
'values' => [
'controller' => 'blog',
'action' => 'read',
'id' => 1,
'format' => '.html',
],
'secure' => false,
'method' => ['GET'],
'routable' => true,
'is_match' => function(array $server, \ArrayObject $matches) {

// disallow matching if referred from example.com
if ($server['HTTP_REFERER'] == 'http://example.com') {
return false;
}

// add the referer from $server to the match values
$matches['referer'] = $server['HTTP_REFERER'];
return true;

},
'generate' => function(\Aura\Router\Route $route, array $data) {
$data['foo'] = 'bar';
return $data;
}
]);

$path = parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH);

$route = $map->match($path, $_SERVER);
if (! $route) {
// no route object was returned
echo "No application route was found for that URI path.";
exit;
}
echo " Controller : " . $route->values['controller'];
echo " Action : " . $route->values['action'];
echo " Format : " . $route->values['format'];