cakePHP 中无法重新声明 config() 错误
我收到错误 Fatal error: Cannot redeclare config() (之前在实时服务器中声明.../basics.php:58。它在我的本地服务器中工作正常,但是当我将网站上传到实时服务器时,我得到了致命错误。 我检查了 config() 是否已声明多次,但仅在 basics.php 文件中声明一次。 还遵循命名约定,因为它在本地服务器中运行良好。它仅在实时站点中显示此类错误。 请为此提出解决方案。
对此的帮助将不胜感激。
I am getting the error Fatal error: Cannot redeclare config() (previously declared in.../basics.php:58, in live server. It works fine in my local server but when i uploaded the site to live server, i got the fatal error.
I checked if the config() was declared multiple times but it's only declared once in basics.php file.
The naming conventions are also followed, as it is working fine in local server. It only displays such error in live site.
Please suggest solution for this.
Help on this will be much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
将 $uses 设置为 array() 并将 $autoRender 设置为 false 如下将解决此问题
set $uses to array() and $autoRender to false as follows will solve this problem
我在运行 Apache 时遇到此错误,它最终与我的
.htaccess
文件被忽略有关 - 我一直在重新配置 Apache,并且不小心将AllowOverride
设置为我的配置文件中没有
,这在某种程度上导致了此错误。因此,简而言之,在您的 http.conf 或站点配置之一中,确保相关目录部分中的 AllowOverride 设置为
All
(或None
以外的其他内容) >),这是我的:I had this error running Apache, and it ended up being related to my
.htaccess
files being ignored - I had been reconfiguring Apache, and had accidentally setAllowOverride
toNone
in my config file, which was somehow causing this error.So, in brief, in either your http.conf or one of your site configs, make sure the AllowOverride in your relevant Directory section is set to
All
(or something other thanNone
), here's mine:如果多次包含“basics.php”,则可能会发生这种情况。您可以使用
include_once/require_once
而不是include/require
来阻止它。但这并不能解释为什么它可以在您的本地网络服务器上运行。
This can happen if "basics.php" was included multiple times. You can prevent it by using
include_once/require_once
instead ofinclude/require
.But this doesn't explain why it's working on your local webserver.
以防万一有人碰巧搜索这个。
我在安装了 cakephp 1.3.11 的 Windows 2003 服务器上遇到了同样的错误。就我而言,这是因为我在一个类关联声明中出现了拼写错误。
我定义了一个 Client 类,其中包含与 Account 类的 hasOne 关联。我错误地向 Client 输入了 className 属性,这创建了一个循环,并导致了 cakePHP 中的 Cannot redeclare config() 错误。
Just in case somebody happens to search for this.
I had the same error on a windows 2003 server with cakephp 1.3.11 installed. In my case it was because I had a typo in one class association declaration.
I had defined a Client class with a hasOne association to a Account class. There I had wrongly typed the className property to Client which created a loop and resulted in the Cannot redeclare config() error in cakePHP.
检查您的 PHP 版本。当您使用比 5.3 更严格的 PHP 版本 5.4 时,会发生该错误,
打开 cake/bootstrap.php 并进行更改以确保使用函数“require_once”加载每个文件一次。代码将是这样的:
Check your PHP version. that errors happens when you use PHP version 5.4 which is more stricter than 5.3
open your cake/bootstrap.php and make changes to make sure every file loaded once with function 'require_once'. The code will be like this: