score:3

Accepted answer

There is no difference. Both ways use one instance of repository factory that is injected by service container.

If you use several entity managers (e.g. for several connections) to make life easier you can use $this->getDoctrine()->getRepository('AppBundle:User')->find($id) for simplicity. It will determine the right entity manager itself.

So I would recommend you to always use way without ->getManager() to not confuse other developers if you have several entity managers.


Related Query

More Query from same tag