我正在将我的项目从CakePHP 1.2升级到1.3。在这个过程中,插件的“神奇”路由似乎是这样的:与插件名称(例如:“论坛”)匹配的控制器名称(例如:"ForumsController")不再自动路由到插件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个路由似乎有点过头了,不是吗?有没有更好的解决方案,可以覆盖我所有的插件,或者至少减少我需要为每个插件设置的路由数量?
发布于 2010-06-15 18:30:58
我想,这个主题Configuration-and-application-bootstrapping涵盖了以下内容:
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-13 17:22:20
您的/app/plugins/myplugin目录中没有myplugin_app_controller.php。
只需创建一个包含以下内容的文件:
<?php
class MypluginAppController extends AppController {
}
?>你将拥有你的插件的所有特性。:)
https://stackoverflow.com/questions/3029776
复制相似问题