2017 © Pedro Peláez
 

cakephp-plugin yaml-routes

implements Routing using yaml file for CakePHP 3

image

guemidiborhane/yaml-routes

implements Routing using yaml file for CakePHP 3

  • Saturday, March 12, 2016
  • by guemidiborhane
  • Repository
  • 0 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yaml Routing for CakePHP 3

implements Yaml Routing which allows you to write routes using yaml language instead of php, (*1)

Requirements

The 3.0 branch has the following requirements:, (*2)

  • CakePHP 3.0.0 or greater.

Installation

  • Install the plugin with composer from your CakePHP Project's ROOT directory (where composer.json file is located)
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)

Example

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();
});

The Versions

12/03 2016

dev-master

9999999-dev

implements Routing using yaml file for CakePHP 3

  Sources   Download

The Requires

 

by Borhane Eddine Guemidi

config cakephp yaml routes