Last active
August 29, 2015 14:24
-
-
Save harikt/5afdf0ba8d9a31a4ba22 to your computer and use it in GitHub Desktop.
Aura.Router v2 default route with wildcard question on irc.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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