auraphp/Aura.Router — Issue #7: Format seems not recognizing
Author: harikt
Created: 2012-01-23 17:33:24+00:00
State: open

The whole code I have is

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' => '(\.json|\.html)?',
],
'values' => [
'controller' => 'blog',
'action' => 'read',
'format' => '.html',
]
]);

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

//echo $path . '

' . print_r( $map->getRoutes() , true );

$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'];

Started server via `php -S localhost:8000`

http://localhost:8000/blog/read/1

`
Controller : blog Action : read
Notice: Undefined index: format in /media/Linux/auracomponentstest/index.php on line 38
Format :
`
Yes the format is not there , so the error , but

http://localhost:8000/blog/read/1.html

http://localhost:8000/blog/read/1.json

all throwing

`Not Found

The requested resource /blog/read/1.html was not found on this server.`