Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Helper classes
  • Hi all,
    I'm creating a module, but now I have a doubt: 2 controllers must use the same method, so I thouth the best solution was to create a "helper" class - or something like that. How is Fuel's logic about this? Where can I put this method and how? Thanks to all!
  • All classes go somewhere in app/classes (or in a module. or a package). Where depends on personal preference. Some just put them in app/classes, so you can access them directly. Some use a folder, like app/classes/helper, and a namespace "Helper" to keep the global namespace clean.
  • Hi Harro, thanks for help.
    It sounds good, but I have a question (hope the last one :-) ): when I have an helper file in a package, I can load it in the boostrap file, what about a module? And what about a normal class in the app/classes folder? 2 examples:
    - If a have a class in app/classes/helper/myhelperfile.php?
    - If a have a class in modules/mymodule/classes/helper/myhelperfile.php? Thanks a lot!
  • Already done, thanks in advance :)
  • Both packages and modules must be loaded, otherwise their namespace isn't registered. This will cause the autoload of the class to fail when you try it use it.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion