php - Do you use repositories in Doctrine2 and Symfony2?
I'm trying to find the best way to design my application and precisely my domain model.
I took a look at most of FOS*Bundle and they abstract the things like this :
Model/
- AbstractUser.php
- AbstractUserManager.php
Entity/
- User.php
- UserManager.php
They don't use Repository at all and all the work is done in the Manager classes.
I used to do something similar but in a different fashion.
I didn't abstract the domain model with abstract and interface (well it looks that it is definitely the way to go) but I had only Entities (the main goal of FOS is to be storage agnostic and allow the use of ODM or ORM).
So I've such structure:
Model/
- Entity/
-- User.php
- Repository/
-- UserRepository.php
Service/
- UserService.php
You bet it, theUserService
is similar to theUserManager
in FOS but it is mostly a Proxy class to theUserRepository
.
What do you think?
How do you organize your domain model, do you have any feedback?
Do the FOS fashion the way to go?
Answer
Solution:
For my bundles, i normally use this method:
Entity/
Repository/
Service/