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 :

- AbstractUser.php
- AbstractUserManager.php
- 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:

- Entity/
-- User.php
- Repository/
-- UserRepository.php
- 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?




For my bundles, i normally use this method:


  • User.php


  • UserRepository.php


  • UserService.php

People are also looking for solutions to the problem: php - How to delete cakephp cached file by name or by name prefix?


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.