views:

170

answers:

1

I have a custom helper whose class name, Image_Core conflicts with Kohana's Image Library ( I can use the Library anywhere except inside my helper )

Is there any other way to call the Image Library, like a namespace or something? ( well, it isn't in a namespace, as I just checked ) or will I have to rename my helper?

Thanks!

NOTE: namespaces are NOT the only solution I'm searching for, don't get stuck on them, please. I just want to know if there's another way to solve name conflicts with Kohana. Thanks.

+2  A: 

There was traditionally no namespacing in PHP which has been a major bone of contention for may developers especially in this arena. Recently they've added support, the documentation of which can be found here and is available from version 5.3 upward the FAQ serves as a good quick reference.

If you're stuck with a lower version then I'm afraid that your limited to renaming your classes and functions with a prefix so they don't interfere.

In your case (should you have 5.4+), you may find that it's up to you to namespace your helper to work around the conflict.

Neel
Thanks! in fact, I should namespace the library, not my helper, because I'm trying to reference the library from within my helper.Anyway, we have PHP 5.2.6 so that won't be possible.Thanks!
Petruza
If you namespace the library you may get into some difficulties should you want to update to the next version of the library (or apply a patch). That is unless you don't plan on updating the library or the overhead is less than the that of altering your code, of course.
Neel
If you were on 5.3+, you could still namespace your helper and use Kohana's absolute namespace path ("\Image_Core" instead of "Image_Core", for instance). Nothing would break then.
Lucas Oman