tags:

views:

37

answers:

1

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!

+2  A: 

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.

Daff
i have updated my question. i want to provide a library and im wondering where to put the kind of business logic i usually have in a controller in a mvc.
never_had_a_name
You shoudl use the PHP autoload function for loading classes. Since you want to provide only a library you should just give on main class or file that needs to be included for your script to use. It is best to check out similar existing scripts and the way they do it.
Daff
but then i'm using Doctrine (ORM) too so i've got model classes. i put them in a model folders? it sounds like a mvc when using models, but i guess that is naturally when using the db too?
never_had_a_name