Model View Controller ... and general classes?

I read some questions related to what I'm going to ask, but I could not figure it out. Let the revision together:

  • Models are classes that manage data from and from a database. Therefore, they relate to classes associated with the database.
  • View is part of the HTML. Mostly page layout.
  • The controller is a logical part of the application and uses models, receives / gives input / output from / to the view.

Wonderful. What if I have to use a class that is not related to the database. Like a class for sessions, a class of templates, or a class of pure logic that help me with some common logic function that I use. Where should these classes go? Are they a model or just library classes?

+4
source share
2 answers

You put it in a model class. The model also handles data logic and validation.

Controllers handle user input only.

Views show what the user sees.

0
source

Most MVC infrastructures support libraries and helpers. Your general classes can go to these directories.

http://codeigniter.com/user_guide/general/helpers.html

http://codeigniter.com/user_guide/general/creating_libraries.html

+1
source

Source: https://habr.com/ru/post/1381152/


All Articles