Setting up magic routes for plugins in CakePHP 1.3?

Posted by Matt Huggins on Stack Overflow See other posts from Stack Overflow or by Matt Huggins
Published on 2010-06-12T19:02:22Z Indexed on 2010/06/12 19:13 UTC
Read the original article Hit count: 235

Filed under:
|
|
|
|

I'm working on upgrading my project from CakePHP 1.2 to 1.3. In the process, it seems that the "magic" routing for plugins by which a controller name (e.g.: "ForumsController") matching the plugin name (e.g.: "forums") no longer automatically routes to the root of the plugin URL (e.g.: "www.example.com/forums" pointing to plugin "forums", controller "forums", action "index").

The error message given is as follows:

Error: ForumsController could not be found.

Error: Create the class ForumsController below in file: app/controllers/forums_controller.php

<?php
class ForumsController extends AppController {
    var $name = 'Forums';
}
?>

In fact, even if I navigate to "www.example.com/forums/forums" or "www.example.com/forums/forums/index", I get the same exact error.

Do I need to explicitly set up routes to every single plugin I use? This seems to destroy a lot of the magic I like about CakePHP. I've only found that doing the following works:

Router::connect('/forums/:action/*', array('plugin' => 'forums', 'controller' => 'forums'));
Router::connect('/forums', array('plugin' => 'forums', 'controller' => 'forums', 'action' => 'index'));

Setting up 2 routes for every single plugin seems like overkill, does it not? Is there a better solution that will cover all my plugins, or at least reduce the number of routes I need to set up for each plugin?

© Stack Overflow or respective owner

Related posts about cakephp

Related posts about plugins