difference between libraries and helpers in php frameworks

前端 未结 5 689
孤街浪徒
孤街浪徒 2020-12-16 02:48

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, retu

5条回答
  •  Happy的楠姐
    2020-12-16 03:43

    Besides the manual that explains these all quite well…

    libraries: Utility classes where object state is important (payment gateways, authentication, etc.)

    helpers: Collections of related functions (not classes) that do repetitive tasks (strings, arrays, etc.)

    plugins: A simple way to drop in third party classes. Typically, the whole process is called with a single wrapper function. (deprecated in the upcoming version 2.0 of CodeIgniter.)

提交回复
热议问题