Can someone point to me how this is done? I want to define plugin specific routes in a config file within the plugin's folder itself.
At the moment I am simply defining routes that are for plugins in my main routes.php file. Which can obviously get very long. So I want to refactor it out to a separate config file and place it in the plugin's folder.
But I saw that there is a code that actually loads plugin-specific routes automatically but I cannot find any documentation on this. In "config/routes.php", there is a line that says
/**
* Load all plugin routes. See the CakePlugin documentation on
* how to customize the loading of plugin routes.
*/
CakePlugin::routes();
Searching through plugin routing here is on a totally different subject. And the plugin documentation mentions nothing about this.
Check out the documentation in this section: Plugin Configuration.
First, add your routes to app/Plugin/YourPlugin/Config/routes.php
And do this 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 the extras you list in the array parameter. If you want to load routes for all your available plugins, do this in app/Config/bootstrap.php:
<?php
CakePlugin::loadAll(array(
array('bootstrap' => true)
));
Good luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With