DEV Community

Rami Gamal
Rami Gamal

Posted on

Where to put the business logic ?

I am writing a web application using PHP without using any framework 'just for learning'.
My app consists of a small routing system, MVC components, some entities that represents the database tables and repository classes that deals with the database.
The controller crate a repository object and that object load its entities from the database then return it as an array to the controller and the controller render the data.
What is the right place to put the domain or business logic,
in the models or repositories

View > Controller > Model > Repository > Database
View < Controller < Model < Repository < Database

Top comments (3)

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao • Edited

If you follow the MVC model and it is a small app. You could go for fat models and thin views approach by putting your business logic into the model.

Collapse
 
ramigaml84 profile image
Rami Gamal

That's not my intent, my intent to put every thing in the right place.
It's not a real application it's just for learning.
Thank you :)

Collapse
 
steelwolf180 profile image
Max Ong Zong Bao

There's not right or not it just depends on what is the use case you are solving.