CakePHP - loading route files from the plugin

Can someone tell me how to do this? I want to define specific plugin routes in the configuration file in the plugin folder itself.

For the moment, I'm just defining the routes that are intended for plugins in my main route.php file. Which, obviously, can become very long. So I want to reorganize it into a separate configuration file and put it in the plugin folder.

But I saw that there is code that actually loads plugins-specific routes automatically, but I can not find any documentation on this. There is a line in config / routes.php that says

/**
 * Load all plugin routes.  See the CakePlugin documentation on 
 * how to customize the loading of plugin routes.
 */
CakePlugin::routes();

The search for plugin routing here is on a completely different subject. And the plugin documentation says nothing about this.

+5
source share
1 answer

Check out the documentation in this section: Plugin Configuration .

First add your routes to the application / Plugin / YourPlugin / Config / routes.php

And do it in app / Config / bootstrap.php:

<?php
CakePlugin::loadAll(array(
    'Blog' => array('routes' => true),
    'ContactManager' => array('bootstrap' => true),
    'WebmasterTools' => array('bootstrap' => true, 'routes' => true),
));

And it will load all your available plugins, but add additional parameters that you list in the array parameter. If you want to load routes for all available plugins, do this in app / Config / bootstrap.php:

<?php
CakePlugin::loadAll(array(
    array('bootstrap' => true)
));

Good luck

+7
source

All Articles