The very common MVC pattern will not be explained in detail here. Let’s talk about Model in detail.
Model should concentrate the data and business logic of the entire application
All business objects involved in the application should be abstracted into Models as much as possible.
To publish an article: Post::create()
, to delete a comment: Comment::delete()
.
The basic Model must be refined
In the design of the Model, it must be designed with as small a granularity as possible. The smaller the granularity, the higher the possibility of reuse.
Design Model hierarchically
Use inheritance
to design a Model that better meets business requirements.
Be thoughtful about naming each Model!
Reference
You know.
The above has introduced the Yii source code interpretation-MVCModel, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.