D
D
Dromok2014-02-20 18:50:42
Zend Framework
Dromok, 2014-02-20 18:50:42

Where to put business logic in Zend2+Doctrine2?

Hi friends!
I'm still new to zend2, and of course, I immediately decided to do everything the right way and connected Doctrine2. And so now it is not clear to me where to take out the logic? I used CakePHP before and everything is clear there.
If everything is clear with simple models, the logic can be stored right there, then what if you use Doctrine2? I mean the concept of thin controllers and thick models.
Example:
User registration. We have a UserController controller with registerAction. There is already a form itself and an entity User with getters and setters. For good, in the controller, you need to call a method like createUser (), and write this method somewhere in the model. Then it is more convenient to write unit tests by testing only the methods themselves in the model. But I was told that it is bad practice to shove this thing into Entity. So, where should I write it? Interested in best practice. Thank you in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vit, 2014-02-20
@fornit1917

Make one more layer - a layer of services. It implements business logic.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question