dev-master
9999999-devimplements Routing using yaml file for CakePHP 3
The Requires
by Borhane Eddine Guemidi
config cakephp yaml routes
implements Routing using yaml file for CakePHP 3
implements Yaml Routing which allows you to write routes using yaml language instead of php, (*1)
The 3.0 branch has the following requirements:, (*2)
php composer.phar require chobo1210/yaml-route "dev-master"
OR, (*3)
add this lines to your composer.json
, (*4)
"require": { "chobo1210/yaml-route": "dev-master" }
And run php composer.phar update
, (*5)
then add this lines to your config/bootstrap.php
, (*6)
Plugin::load('YamlRoute', ['routes' => true]);
then create your routes file config/routes.yml
, (*7)
Routes: scope: / index: path: / controller: Pages action: display arg: home pages: path: /pages/* controller: Pages action: display voyage: path: /blog/:slug-:id controller: Posts action: view args: _name: view_single_post pass: - id - slug id: '[0-9]+'
gives this, (*8)
Router::scope('/', function($routes) { $routes->connect('/', ['controller' => 'Pages', 'action' => 'display', 'home']); $routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']); $routes->connect('/blog/:slug-:id', ['controller' => 'Posts', 'action' => 'view'], ['_name' => 'view_single_post', 'pass' => ['id', 'slug'], 'id' => '[0-9]+']); $routes->fallbacks(); });
implements Routing using yaml file for CakePHP 3
config cakephp yaml routes