B
B
boozzd2015-02-07 18:13:12
Doctrine ORM
boozzd, 2015-02-07 18:13:12

How to properly organize the application structure?

There is a project on ZF2 and doctrine is used. Now the module structure looks like this:
cc77c40329f64d029195c3ab5cb53ab8.png
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

2 answer(s)
N
Nicholas Lindemann, 2015-02-08
@boozzd

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...

M
Maxim, 2015-02-07
@maxloyko

the very place of methods for working with the database in the model, tobish in entities or repositories

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question