Search code examples
phpmodel-view-controlleroopclassmodels

Model View Controller ... and generic classes?


I read some questions related to what I'm going to ask but I couldn't really figure it out. Let's revision together:

  • Models are classes that manage datas from and to database. So they are classes database-related.
  • View is the HTML part. Basically the layout of the page.
  • Controller is the logic part of the application and uses models, gets/give input/output from/to the view.

Wonderful. What if I have to use a class that is not database related. Like a class for Sessions, a Template class or a pure logic Class that help me with some common logic function I use. Where should this classes go? Are they Model or just Library classes?


Solution

  • You put it on the model class. Model handles data logic and validations too.

    Controllers only handles user input.

    Views display what the user sees.