CakePHP 2.0 插件 URL
尝试让 CakePHP 与控制器、视图或模型的子文件夹一起工作并没有真正起作用,根据我所读到的内容,我需要使用“插件”。现在我有以下文件夹结构:
/app/Plugin/Manager/
/Controller
CandyController.php
/Models
/View
/Candy
viewCandy.ctp
ManagerAppController.php
ManagerAppModel.php
当我尝试将 url 设置为: http://localhost/Manager /Candy/viewCandy/123。我收到错误消息:“ManagerController 不存在”。为什么 CakePHP 没有发现它应该在 Manager 插件文件夹中查找?
Trying to get CakePHP work with subfolders for Controllers, Views, or Models is not really working and from what I've read I need to use "Plugins". Right now I have the following folder structure:
/app/Plugin/Manager/
/Controller
CandyController.php
/Models
/View
/Candy
viewCandy.ctp
ManagerAppController.php
ManagerAppModel.php
When I try and set my url to: http://localhost/Manager/Candy/viewCandy/123. I get the error message: "ManagerController does not exist". Why is CakePHP not picking up that it should look in the Manager plugin folder?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
现在 2.0 已经发布了,文档变得更加充实了。 说明书的插件部分对此进行了描述。
他们建议将其放入 bootstrap.php 而不是 routes.php:
Now that 2.0 has been released the docs are fleshed out a bit more. This is described in the Plugin section of the cookbook.
They suggest putting this in bootstrap.php instead of routes.php:
解决方案如下:
转到 /app/Config/routes.php 并在
CakePlugin::routes( 行之后添加行
。就我而言,它是第 40 行。CakePlugin::load(array('YourPluginName'));
);基本上 CakePHP 2.0 不会自动加载插件。我认为这很好,但实际上没有任何相关文档。
Here is the solution:
Go to /app/Config/routes.php and add the line
CakePlugin::load(array('YourPluginName'));
after the lineCakePlugin::routes();
. In my case it was line 40.Basically CakePHP 2.0 doesn't automatically load plugins. I think that's fine and dandy, but there isn't really any documentation for this.