即使控制器存在,控制器指定的错误也无效

发布于 2024-12-09 04:02:53 字数 1345 浏览 0 评论 0原文

我有一个驼峰式控制器名称,名为 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

断爱 2024-12-16 04:02:53

这是因为 Windows 不区分大小写,而基于 Linux 的操作系统则区分大小写。

来自 ZendFramework 手册:

Zend_Controller 的调度程序然后获取控制器值和映射
它到一个类。默认情况下,控制器名称采用标题大小写形式,并且
附加“控制器”一词。因此,在我们上面的例子中,
控制器路线图映射到类 RoadmapController。

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

一般来说,当使用多字控制器时,只需确保类的第一个字母和控制器中的 C 是大写的。

This is because Windows is not case sensitive and Linux based operating systems are.

From the ZendFramework manual:

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.

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.

最冷一天 2024-12-16 04:02:53

我过去也遇到过非常类似的问题(我也在Windows中开发并将应用程序部署到Linux服务器)。我的解决方案是重命名类和文件,删除大写字母。在你的情况下,它将是:

File Name: MenuitemController.php
Class Name: MenuitemController

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:

File Name: MenuitemController.php
Class Name: MenuitemController
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文