Loading extended helper from package #777

davidbehler opened this Issue Dec 13, 2011 · 5 comments


None yet
4 participants

davidbehler commented Dec 13, 2011

I'm running 2 apps on the same server and they share the system folder and a folder called "common" where I put custom/new libraries they share and I did not want to put in both app folders. I can do this using the packages autoload option and it works just fine. Now I got a extended helper that they both share as well and that's where it all fails :)

According to the user guide if I want to extend a helper I should just create a new file in my application/helper folder with the same name as the original file and then just prepend it with the subclass suffix, in my case the god old 'MY_'. I did exactly this but instead of putting it in my application/helpers folder, I put the file in common/helpers (my shared package folder for both apps), but the helper just wasn't loaded.

So I had a look at the code and in the system/core/Loader.php on line 502-523 it only checks the application folder for a file with the subclass prefix but not the package folder(s). It's the same for libraries, the Loader only checks for extended libraries in the application folder and only loads new libraries (those that don't exist in the system folder or overwrite those) from the package folder.

So loading extended anything from a package is not possible, only libraries/helpers that overwrite existing ones or are completely new can be loaded from packages. I guess that's because the subclass prefix can be changed to whatever you want and if you prefix your packaged files with 'YOUR_' and then someone tries to use your package but has their prefix set to 'MY_' it won't work at all.

Do you see a way of solving this?


narfbg commented Jan 11, 2012

What version of CI are you using? Haven't tested it, but in 2.1 this looks to be handled properly.


davidbehler commented Jan 11, 2012

2.1.0 :)

It's been a while since I looked into this and I'll investigate some more in the next few days and maybe I'll try to fix it myself and make a pull request.


dmmihaylov commented Feb 4, 2012

It's not possible yet, indeed. Seems like a major issue in Loader, which makes the package useless when it comes to extending the core.

I'm having the same issue.
Is there any plans to change this behaviour without hacking/extending CI_Loader ?

@narfbg narfbg added a commit that referenced this issue Nov 12, 2012

@narfbg narfbg Fix issue #777 12d7b46

narfbg commented Nov 12, 2012

Fixed, see the above commit.

narfbg closed this Nov 12, 2012

@nonchip nonchip pushed a commit to nonchip/CodeIgniter that referenced this issue Jun 29, 2013

@narfbg narfbg Fix issue #777 d22ff7b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment