CodeIgniter: Decision making for creating of library & helper in CodeIgniter

前端 未结 6 1386
孤街浪徒
孤街浪徒 2020-12-23 02:10

After developing in CodeIgniter for awhile, I find it difficult to make decisions when to create a custom library and when to create a custom helper.

I do understand

6条回答
  •  北海茫月
    2020-12-23 02:53

    There is a question I ask myself when deciding this that I think will help you as well. The question is: Am I providing a feature to my framework or am I consolidating?

    If you have a feature that you are adding to your framework, then you'll want to create a library for that. Form validation, for example, is a feature that you are adding to a framework. Even though you can do form validation without this library, you're creating a standard system for validation which is a feature.

    However, there is also a form helper which helps you create the HTML of forms. The big difference from the form validation library is that the form helper isn't creating a new feature, its just a set of related functions that help you write the HTML of forms properly.

    Hopefully this differentiation will help you as it has me.

提交回复
热议问题