2

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.

PeeHaa
  • 71,436
  • 58
  • 190
  • 262
Sudhir Bastakoti
  • 99,167
  • 15
  • 158
  • 162

5 Answers5

2

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';
        }

    }
Liang
  • 767
  • 10
  • 13
2

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>
cincodenada
  • 2,877
  • 25
  • 35
  • 1
    Yes, this is True. And before you have to enable mod_rewrite, for example in Ubuntu `sudo a2enmod rewrite; sudo service apache2 restart` Thanks – Hey Teacher Jun 14 '12 at 19:19
1

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';
risnandar
  • 5,513
  • 1
  • 26
  • 17
1

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.

German Rumm
  • 5,782
  • 1
  • 25
  • 30
  • yea, its the same code in local and live but its works fine in local but showing error in live, and i've checked for multiple redeclaration of config() and basics.php, but its only declared once and included once, but still i'm facing this problem – Sudhir Bastakoti Jan 13 '11 at 10:08
  • For me, this was it. As simple as an additional require, instead of require_once in my ROOT/index.php: require CORE_PATH . 'cake' . DS . 'basics.php'; – zmonteca Sep 18 '12 at 05:16
1

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.

user904886
  • 11
  • 1