سؤال

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.

هل كانت مفيدة؟

المحلول

set $uses to array() and $autoRender to false as follows will solve this problem

   class IndexController extends AppController
    {

        public $uses = array();
        public $autoRender = false;

        public function index()
        {
            echo 'test';
        }

    }

نصائح أخرى

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 set AllowOverride to None 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 than None), here's mine:

<Directory /var/www>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All 
    Order allow,deny
    allow from all
</Directory>

This can happen if "basics.php" was included multiple times. You can prevent it by using include_once/require_once instead of include/require.

But this doesn't explain why it's working on your local webserver.

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.

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:

require_once CORE_PATH . 'cake' . DS . 'basics.php';
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
require_once LIBS . 'object.php';
require_once LIBS . 'inflector.php';
require_once LIBS . 'configure.php';
require_once LIBS . 'set.php';
require_once LIBS . 'cache.php';
Configure::getInstance();
require_once CAKE . 'dispatcher.php';
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top