Alex Rivera | Logout

difference between libraries and helpers in php frameworks

Asked 2010-02-01T05:40:45.200
10

if i've got string functions i use a lot, should i put them in a helper class or a library class?

functions like: truncate string if longer than 30 characters, return a random string, make all lower cases and so on. these are functions that i probably don't need to create an object for. it's better to use them as static methods.

should i put them in a library class or a helper class?

when do i know when to put where?

Edit
Report

1 Answer

4

I assume you are using CodeIgniter.

Since you already write that you don't need to instantiate an object and will use it in it's static methods, then making it into helper will be make sense than making it into library.

In CI, helpers is also managed, once loaded, second attempt to load it will be omitted. You can open the CI's build in helper to learn what it does, then compare it with libraries. By knowing the purpose, you can then decide yourself, helpers or libraries.

answered 2010-02-01T09:11:35.793

Your Answer