微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

zend-framework – 无效的控制器指定错误,即使控制器存在

我有一个名为MenuItem的camelcased控制器名称.而且我也为这个特定的控制器创建了一个路由器

$routeMenuItem = new Zend_Controller_Router_Route('/menu-item/:action/:menu/:parent/:id/*',array(
        'controller'    => 'MenuItem','action'        => 'index','menu'          => 1,'parent'        => 0,'id'            => 0        
    ));

不,当我导航到这个路线时,让我们说/ menu-item / index / 2我得到一个错误,无效的控制器指定(MenuItem)错误.

但是我在linux环境下部署时遇到了这个问题.但是,在Windows环境中进行开发时,它可以正常工作.

怎么解决这个?

更多信息

控制器:

File Name: MenuItemController.PHP
Class Name: MenuItemController

堆栈跟踪

#0 /../library/Zend/Controller/Front.PHP(954): Zend_Controller_dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http),Object(Zend_Controller_Response_Http))
#1 /../library/Zend/Application/Bootstrap/Bootstrap.PHP(97): Zend_Controller_Front->dispatch()
#2 /../library/Zend/Application.PHP(366): Zend_Application_Bootstrap_Bootstrap->run()
#3 /../public/index.PHP(25): Zend_Application->run()
#4 {main}

请求参数

array (
  'action' => 'index','menu' => '2','controller' => 'MenuItem','parent' => 0,'id' => 0,)

解决方法

这是因为Windows不区分大小写且基于Linux的操作系统.

从ZendFramework手册:

Zend_Controller’s dispatcher then takes the controller value and maps
it to a class. By default,it title-cases the controller name and
appends the word Controller. Thus,in our example above,the
controller roadmap is mapped to the class RoadmapController.

这意味着MenuItemController.PHP和MenuitemController.PHP是两个不同的东西,因此自动加载器无法找到匹配项.

通常,在使用多字控制器时,只需确保只有类的第一个字母和控制器中的C大写.

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐