0
votes

I've started using HMVC in Codeigniter with Modular Extension and i want to create a set of methods avalaible in the whole application.

For example i've this three methods:

  • a method to retrieve te app name
  • a method for getting the right view folder depending on the user agent
  • a method to load assets

What's the best way to do this:

  1. I'm using a model inside a module which is then requested from all other modules
  2. I may extend or create a library/helper

now i'm using the first solution but I have come to doubt that it can slow down the application.

1
if its really only those 3 methods couldnt you just have that as a stand alone model and autoload it? - Rooster
yes i'm doing so but then i may have to use also a controller and i don't want to change all later - Matteo Pagliazzi
ya, both approaches are valid. Wouldn't you just be using/loading the model to do all those things from the 'front' controller and then calling another controller from there anyway? It seems like your model approach would be fine then. - Rooster
Personally I would create this as a helper and then autoload the helper. I'm not sure of your system, but by requesting that module in every other module, you're giving the requesting module access to everything in the module containing your "global" functions. (Just saying that is confusing). If you're okay with that then go for it. But as I stated above, I'd seperate these out into a helper that was autoloaded. - Matt Moore
@matt also in a helper i would have access to all its methods from the requestin controller, right? anyway i may also autoload the model - Matteo Pagliazzi

1 Answers

0
votes