Created
February 9, 2015 07:32
-
-
Save robertscherer/e6afe139441e66c2d75f to your computer and use it in GitHub Desktop.
This file contains hidden or 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::defaultRouteClass('Route'); | |
Router::scope('/', function ($routes) { | |
/** | |
* Here, we are connecting '/' (base path) to a controller called 'Pages', | |
* its action called 'display', and we pass a param to select the view file | |
* to use (in this case, src/Template/Pages/home.ctp)... | |
*/ | |
$routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']); | |
/** | |
* ...and connect the rest of 'Pages' controller's URLs. | |
*/ | |
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']); | |
/** | |
* Connect catchall routes for all controllers. | |
* | |
* Using the argument `InflectedRoute`, the `fallbacks` method is a shortcut for | |
* `$routes->connect('/:controller', ['action' => 'index'], ['routeClass' => 'InflectedRoute']);` | |
* `$routes->connect('/:controller/:action/*', [], ['routeClass' => 'InflectedRoute']);` | |
* | |
* Any route class can be used with this method, such as: | |
* - DashedRoute | |
* - InflectedRoute | |
* - Route | |
* - Or your own route class | |
* | |
* You can remove these routes once you've connected the | |
* routes you want in your application. | |
*/ | |
$routes->fallbacks('InflectedRoute'); | |
}); | |
/** | |
* Load all plugin routes. See the Plugin documentation on | |
* how to customize the loading of plugin routes. | |
*/ | |
Plugin::routes(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment