【问题标题】:How to fix "Error: [MissingControllerException] " in CakePHP?如何修复 CakePHP 中的“错误:[MissingControllerException]”?
【发布时间】:2014-07-26 08:09:40
【问题描述】:

升级 php 版本后,现在它在我的基于 CakePHP 的网站上显示以下错误消息。

 Error: [MissingControllerException] Controller class Gems.pngController could not be found.
 #0 /home/example/public_html/dev/app/webroot/index.php(111):       
 Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
 #1 {main} - http://www.example.com/gems.png

我在 .htaccess 中使用以下代码(在 webroot 中)

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>

此外,它会在网页上显示警告消息。 "严格 (2048): FileComponent::startup() 的声明应该与 Component::startup(Controller $controller) [APP/Controller/Component/FileComponent.php, line 0] 兼容"

我真的很难找到所有问题的解决方案。

提前谢谢

【问题讨论】:

  • 我想gems.png 存在,不是吗?如果重命名.htaccess 文件,它会正确加载吗?
  • 是的,如果我去example.com/gems.png,那么我可以看到图像。
  • 我无法复制。并且 PHP 版本在这里不应该是相关的,因为重写规则的重点是完全避免为资产调用 PHP。奇怪...
  • 看到这个错误我也觉得很奇怪,因为除了php版本升级没有任何变化。
  • 至于警告,使用 php 5.4,在 cakephp 中,当你有功能时,例如beforeSave() 或在您的组件中启动时,您也应该放置函数的参数。所以在你的 FileComponent 组件中将启动函数更改为startup(Controller $controller)。在 beforeSave 的情况下,它应该是 beforeSave($options = array())

标签: php cakephp exception


【解决方案1】:

我使用的是 CakePHP 2.8 和 PHP 5.6,升级到 PHP 7.2 并得到同样的错误!

使用 PHP 7.0 而不是 PHP 7.2,一切恢复正常。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-08-17
    • 1970-01-01
    • 2020-04-20
    • 2017-10-08
    • 1970-01-01
    • 1970-01-01
    • 2021-08-11
    • 1970-01-01
    相关资源
    最近更新 更多