-
Notifications
You must be signed in to change notification settings - Fork 2
Routes
Carlos Eduardo edited this page Jun 30, 2016
·
2 revisions
On file config.php
, inside of application folder, you can set the routes that you wants.
use \Core\Routes\Router;
// Set Error 404 - Alias to Router::error(404, [...])
Router::notfound([
'controller' => 'Error',
'action' => 'index'
]);
// Register Error 403
Router::error(403,[
'controller' => 'Error',
'action' => 'denied'
]);
// Register default route: /
Router::main([
'controller' => 'Main',
'action' => 'index'
]);
// Register route: /index, with copy of main route;
Router::route('/index', Router::main());
// Register route: /singin
Router::route('/singin', [
'controller' => 'Login',
'action' => 'index'
]);
// Register route: /post/<Numeric Param>
Router::route('/post/:id',[
'controller' => 'Main',
'action' => 'teste'
])->params([
'id' => '\d+' // '<Param Name>' => '<Regular Expression>'
]);
// Register route: /post/<Alphanumeric Param>
Router::route('/post/:slug',[
'controller' => 'Main',
'action' => 'action'
])->params([
'slug' => '[a-zA-Z0-9\-_]+' // '<Param Name>' => '<Regular Expression>'
]);
// Register route: /post/<Date on Format NNNN-NN-NN>/<Alphanumeric Param>
Router::route('/post/:date/:slug', [
'controller' => 'Main',
'action' => 'pdate'
])->params([
'date' => '[0-9]{4}-[0-9]{2}-[0-9]{2}', // '<Param Name>' => '<Regular Expression>'
'slug' => '[a-zA-Z0-9\-_]+' // '<Param Name>' => '<Regular Expression>'
]);