guemidiborhane/yaml-routes

There is no license information available for the latest version (dev-master) of this package.

implements Routing using yaml file for CakePHP 3

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 1

Watchers: 3

Forks: 0

Open Issues: 0

Type:cakephp-plugin

dev-master 2016-03-12 00:26 UTC

This package is auto-updated.

Last update: 2024-04-19 21:35:41 UTC


README

implements Yaml Routing which allows you to write routes using yaml language instead of php

Requirements

The 3.0 branch has the following requirements:

  • 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

add this lines to your composer.json

"require": {
  "chobo1210/yaml-route": "dev-master"
}

And run php composer.phar update

then add this lines to your config/bootstrap.php

Plugin::load('YamlRoute', ['routes' => true]);

then create your routes file config/routes.yml

##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

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