Answer the question
In order to leave comments, you need to log in
How to properly organize the application structure?
There is a project on ZF2 and doctrine is used. Now the module structure looks like this:
I want to extract methods from entities (Doctrine Entity) so that only getters and setters remain in them. What is the best way to organize this? Thank you.
Answer the question
In order to leave comments, you need to log in
First, why use Doctrine ORM 2 in Zend Framework 2? The whole idea and feature of ZF2 itself is that it is pure PHP. That is why it shows itself best in performance. You probably also use some kind of template engine, for example twig ...
Secondly, if you decide to use ORM, then use the Symfony 2 framework, it is very well integrated there, and all kinds of solutions for a particular task are provided.
Thirdly, about the organization, indeed the entity should store protected / private properties, and access methods to them. You can put all operations on getting data into the Repository directory, and put methods into the EntityRepository class (instead of Entity, insert the name of your entity), this is how it is done in SF2. In fact, you are free to choose the organization, and you can do as you wish. For example, you can put the whole thing in either a Model or a Service. Of course, you can just shove this thing into the Controller, but you shouldn't do that.
The choice is yours...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question