Which ORM to use with Symfony2?

Timothée Martin picture Timothée Martin · Nov 2, 2011 · Viewed 9.3k times · Source

I'm starting a new project with Symfony2 and I'm not really sure which ORM to choose. I've heard some bad things about Doctrine2, especially when it comes to inheritance and DQL. It seems like Propel is back from the dead, but on the other hand, there's no warranty that it will last forever.

Do you have any advice ?

Answer

William Durand picture William Durand · Nov 2, 2011

I can tell you Propel is the most suitable ORM to use with Symfony2. It works fine and no plan to stop activities on it. The Propel2 project is on its way to be better than Propel 1.6.x (which is ever really great).

Don't hesitate to use Propel, many users including Sensio Labs are using it !

Here is the Propel doc for Symfony2: http://www.propelorm.org/documentation/#working_with_symfony2

Note: There is a related topic on Stack Exchange: https://softwareengineering.stackexchange.com/questions/48760/should-i-choose-doctrine-2-or-propel-1-5-1-6-and-why/117078#117078

Some points I forgot:

  • Behaviors are part of Propel, no one provided in Doctrine2. That means Propel officially supports them and provides support/improvements. Not sure about Doctrine ones.
  • Propel is really fast. I agree Doctrine2 is better than Propel for mass insertions.
  • Propel is 10 years old, stable and used by a lot of people.
  • No yet another language to learn with Propel.
  • Propel2 is really object oriented, thanks to fluent APIs.
  • Doctrine2 ORM doesn't share the same API with ODM, so you may use Propel with D2 ODM like D2 ORM and ODM, there are no pros here.
  • Propel uses code generation for specific platforms, so it's optimized for your needs, and fast thanks to runtime & generator parts.

Some points I like in Doctrine2:

  • Annotations.
  • The whole code because it's quite recent.

The problem is not about Doctrine DBAL but more about Doctrine ORM. And Propel2 is on its way to improve the whole Propel 1.6.x code.

Oh, and I used Doctrine2 for a long time ;)