即使控制器存在,控制器指定的错误也无效
我有一个驼峰式控制器名称,名为 MenuItem。而且我还为这个特定的控制器创建了一个路由器,作为
$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,
)
I have a camelcased controller name called MenuItem. And Also I have created a router for this particular controller as
$routeMenuItem = new Zend_Controller_Router_Route('/menu-item/:action/:menu/:parent/:id/*', array(
'controller' => 'MenuItem',
'action' => 'index',
'menu' => 1,
'parent' => 0,
'id' => 0
));
No, when I navigate to this route lets say /menu-item/index/2
I get a error, Invalid controller specified (MenuItem)
error.
However I am encountering this problem while deploying under linux environment. But, during development in Windows environment it works fine.
How to solve this?
More Information
Controller:
File Name: MenuItemController.php
Class Name: MenuItemController
Stack Trace
#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}
Request Parameters
array (
'action' => 'index',
'menu' => '2',
'controller' => 'MenuItem',
'parent' => 0,
'id' => 0,
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是因为 Windows 不区分大小写,而基于 Linux 的操作系统则区分大小写。
来自 ZendFramework 手册:
这意味着 MenuItemController.php 和 MenuitemController.php 是两个不同的东西,因此自动加载器无法找到匹配项。
一般来说,当使用多字控制器时,只需确保类的第一个字母和控制器中的 C 是大写的。
This is because Windows is not case sensitive and Linux based operating systems are.
From the ZendFramework manual:
This means that MenuItemController.php and MenuitemController.php are two different things, thus the autoloader is unable to find a match.
As a rule, when using multi word controllers just make sure that only the first letter of the class and the C in controller is capitalized.
我过去也遇到过非常类似的问题(我也在Windows中开发并将应用程序部署到Linux服务器)。我的解决方案是重命名类和文件,删除大写字母。在你的情况下,它将是:
I had a very similar problem in the past (I was also developing in Windows and deploying the application to a Linux server). My solution was to rename the classes and files, to remove the uppercases. In your case, it would be: