0

我正在将我的项目从 CakePHP 1.2 升级到 1.3。在此过程中,似乎控制器名称(例如:“ForumsController”)与插件名称(例如:“forums”)匹配的插件的“神奇”路由不再自动路由到插件 URL 的根目录(例如:“www.example.com/forums”指向插件“论坛”,控制器“论坛”,动作“索引”)。

给出的错误信息如下:

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';
}
?>

事实上,即使我导航到“www.example.com/forums/forums”或“www.example.com/forums/forums/index”,我也会得到同样的错误。

我是否需要为我使用的每个插件明确设置路由?这似乎破坏了我喜欢 CakePHP 的许多魔力。我只发现做以下工作:

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

为每个插件设置 2 条路由似乎有点矫枉过正,不是吗?有没有更好的解决方案可以覆盖我所有的插件,或者至少减少我需要为每个插件设置的路由数量?

4

2 回答 2

1

我想,该主题配置和应用程序引导涵盖:

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

也看看这张票:http ://cakephp.lighthouseapp.com/projects/42648/tickets/750-plugin-route-problem-when-acl-and-auth-components-used#ticket-750-5 ( Cake 1.3 移除了魔法插件路由)。

于 2010-06-15T10:30:57.550 回答
-1

您的 /app/plugins/myplugin 目录中没有 myplugin_app_controller.php。

只需创建一个包含以下内容的文件:

<?php
class MypluginAppController extends AppController {

}
?>

您将拥有插件的所有功能。:)

于 2010-06-13T09:22:20.340 回答