开发者

where to put business logic in a library?

i'm going to create a library that consists of a lot of separate classes.

i'm very familiar with mvc but have never created a pure library before.

i wonder where i should put the business logic? the kind of logic that usually resides in a controller in a mvc.

should it be in a class or in a "bootstrap" file?

and should one file include every class, or should only one class include its classes it uses?

to clarify: my goal is开发者_如何转开发 not to create a mvc, but a pure library eg. email or guestbook that others can use.

thanks!


There is a difference in a often mixed up terminology between framework and library:

A library is a collection of classes that offer a certain functionality. The user of that library is responsible for providing all the information necessary and instanciating these classes (you can provide higher level abstraction classes with an interface as simple as possible).

A framework is a collection of classes that provides a frame to how an application or a part of an application is being built, e.g. by forcing the user of that framework to follow the MVC pattern (where the user has to provide appropriate Model, View and Controller classes). This usually leads to a so called inversion of control (IOC) where not the user of the framework is responsible for instantiating all classes and providing all necessary information but the framework asks for some certain kinds of classes to be implemented and (configuration) files to be provided.

So first it would be on you to decide if you want to provide a library of a framework. A framework in PHP usually uses a bootstrap file.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜