Skip to content

Instantly share code, notes, and snippets.

@harikt
Last active August 29, 2015 14:24
Show Gist options
  • Save harikt/5afdf0ba8d9a31a4ba22 to your computer and use it in GitHub Desktop.
Save harikt/5afdf0ba8d9a31a4ba22 to your computer and use it in GitHub Desktop.
Aura.Router v2 default route with wildcard question on irc.
<?php
// router instantiation
$router->add('default_route', '/{controller}')
->setWildcard('other')
->addValues(array(
'action' => 'build_your_controller',
));
;
$route = $router->match($path, $_SERVER);
if ($route) {
$class = $action_class = $route->params['action'];
if ($action_class == 'build_your_controller') {
// you need to build your controller here.
// $route->params['other'] will be an array
// $route->params['controller']
$class = 'MyApp\\' . ucfirst(strtolower($route->params['controller'])) . implode('/', $route->params['other']);
}
// See https://github.com/auraphp/Aura.Router/#as-a-micro-framework
$obj = new $class();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment