Welcome Guest, Not a member yet? Register   Sign In
Fatal error: Cannot redeclare *insert helper here*

Hey all,

First off, I've read all the threads from searching "cannot redeclare". None of my class names conflict with other classes, and there are no other loaders for these helpers.

I have a library that I'm trying to load a controller and a model into, no matter which one I try to load, I first get:
Fatal error: Cannot redeclare site_url() (previously declared in /var/www/httpdocs/site/helpers/url_helper.php:40) in /var/www/httpdocs/site/helpers/url_helper.php on line 40
I've tried removing the helpers from config/autoload.php, but it keeps trowing an error on the next helper, all the way down to some sort of 'no helpers defined' errmsg.

We're porting old authentication code to the FreakAuth CI addon, and it works great. I'm wondering if this addon has anything to do with it though.

FWIW, all the auth stuff works fine, it's just when I try to include some of my old classes that it starts throwing errors. I've commented everything out of the controller I'm loading, so it's the act of just including the controller that is bombing it out, nothing in the controller itself (just an echo in there). I'm loading the controller like this:
Any ideas why this is happening?


Are you sure you are not loading the url helper twice somewhere?

i.e. you autoloaded it, and then loaded it again from another class/controller?

If I don't remember badly, the url helper get autoloaded in the autoload_demo.php file included in FreakAuth.


1) redeclare thing
Helpers (like other CI elements) can be loaded several times, CI checks for this with
if (isset($this->_ci_helpers[$helper]))
Try to search this string: 'function site_url' in your files. It must be in the url_helper AND at another place.

When you say 'it keeps trowing an error on the next helper' I guess the function is another one (not site_url). I'm curious, could you make a list of those 'bad functions'?

2) auth addon
Could you detail a bit 'old authentication code'? What do you port to what?

3) loadController
This is not a CI function, I can't say anything about those errors...

Hi guys,
having the same problem. I didn't request URI helper in my application at all, but still get the same message.

Hi coder_cotton,

Have you checked your error logs? I usually find they are more descriptive.

>>> I have a library that I’m trying to load a controller and a model into...
Is that statement correct? Shouldn't that be "I have a controller that I'm trying to load a library and a model into"?



Theme © iAndrew 2016 - Forum software by © MyBB