CodeIgniter Forums
Why should I write a library rather than a helper? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Why should I write a library rather than a helper? (/showthread.php?tid=13011)



Why should I write a library rather than a helper? - El Forum - 11-07-2008

[eluser]surfgatinho[/eluser]
I have a few functions that I need to call from various controllers. I have previously written helper for such functions, e.g. to create a dynamic menu.

Now I'm wondering what reasons I'd want to write a library rather than a helper (except to keep the code more OO)?


Why should I write a library rather than a helper? - El Forum - 11-07-2008

[eluser]OES[/eluser]
I was told to think of it this way.

If you have one off functions then helpers do the trick like you have said. But lets say you building a app eg a Calander.

It would make sense to add all functions in one library for the calendar. You just have to look at CI Librarys. All functions are for the same thing.

Hope that makes sense!


Why should I write a library rather than a helper? - El Forum - 11-07-2008

[eluser]surfgatinho[/eluser]
Thanks for the reply. I think my case might be borderline so it's not going to matter much either way.
I may go for a library just to be puritanical and keep it all OO


Why should I write a library rather than a helper? - El Forum - 11-07-2008

[eluser]Rick Jolly[/eluser]
Rule of thumb: If you can use a helper, then do. Only when a helper won't work (you need instance variables), should you use a library.