Decoupling and Doctrine

  decoupling, doctrine, php, solid, symfony

How to work with Doctrine in order to keep everything decoupled as much as possible and also to prepare for replacing Doctrine someday for some other data-mapper solution?

I understand that I should use XML / Yaml / Php Mappings instead of @Annotations in order to keep Entities and Mappings separated to achieve SRP i.e.

Should I use Association Mappings?
I see that Associations cause coupling but I like to work with objects.

Should I use DQL in Repositories or i.e. NamedNativeQueries with SqlResultSetMappings written in XML / Yaml for a sustainable decoupled code?

What are the best practices?

Source: Symfony Questions

LEAVE A COMMENT