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!
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.