views:

191

answers:

2

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?

A: 

You don't have myplugin_app_controller.php in your /app/plugins/myplugin directory.

Just create a file containing following:

<?php
class MypluginAppController extends AppController {

}
?>

And you will have all your plugin's features. :)

Nik
No, I definitely have that file. Thanks though!
Matt Huggins
A: 

I guess, that topic Configuration-and-application-bootstrapping covers that:

App::build(array(
    'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/')
));

Also take a look at this ticket: http://cakephp.lighthouseapp.com/projects/42648/tickets/750-plugin-route-problem-when-acl-and-auth-components-used#ticket-750-5 (Cake 1.3 had removed magic plugin routes).

bancer
Thanks bancer, I should have mentioned that I tried providing a custom plugins array to `App::build()`, but that didn't help either. I am using AuthComponent, so perhaps I'm running into the same issue as this ticket describes. I can't check now since I'm at work, but thanks for the heads up on that reported issue!
Matt Huggins