Search code examples
symfony1doctrinesymfony-1.4propel

Propel or Doctrine; which is better ORM for Symfony 1.4


I've live project experience with CodeIgniter and Cake PHP. However now I need to work on a huge project for which both are unsuitable. I'm nearly decided to go with symfony 1.4 (2.0 isn't an option, according to my client's requirements).

In Symfony 1.4 too, I'm confused between ORM choice: Doctrine or Propel? I went through few links. Best found so far is PHP ORMs: Doctrine vs. Propel.

However all those comparisons seem a minimum of two years old and definitely the world would have changed a lot since than. I do not have any issue with coding style; I'm fine with all Active Record, Criteria, DQL or whatever. For me, performance is most important than coding style comes at last. I'm mainly concerned about performance while dealing lot of data, probably millions of rows from multiple tables under clustered database. Unfortunately right now my experience is not sufficient to take independent decision on that matter.

Can anyone please shed some light on performance of Propel/Doctrine under Symfony 1.4? Other than performance, is there any other notable factor (except coding style) which one should take care while choosing PHP ORM?


Solution

  • tl;dr: I used Doctrine for a long time and I will choose Propel if I have to start something new.

    This is such a common question that has nearly no good answer. But I will just give you my point of view.

    I've worked with Doctrine since the first alpha (and with the old symfony 0.63). We choose Doctrine instead of Propel because Doctrine supported PDO (which is native to PHP) and Propel was still running on Creole (which isn't native). Creole was very slow in comparison to PDO (of course).

    Recently, Doctrine added lost of a magic. I mean, you could call getField, findOneByField for everything and it would return what you want. It was something really great instead of having to build your own getter and setter. Magic was really trendy at this time.

    Writing query using Doctrine was really easy instead of the painful Criteria and Criterion from Propel, which was really verbose. I was really fan of Doctrine and recommended to everyone to start using it instead of Propel.

    Then, Propel switch to PDO as of 1.3 and started to have a nice API to write query, almost the same approach as Doctrine. The main difference was that Propel generate all magic things while Doctrine build on the fly. That's the biggest difference I think.

    Propel doesn't have any magic in this code. It generates all getter/setter, join, etc .. when you build your model. Doctrine does every thing when it run the query. That's okay for small to medium project, but it starts to be bigger, it will become a slow solution. And it's great for debugging too, because you find the code in generated classes, you don't have to jump from classes to classes to find the global method that handle this case.

    Both ORM use behaviors. I love behaviors. They are handled in different way in Doctrine and Propel. Doctrine still use its magic to handle them where Propel generates everything from the behavior inside the class (one more point from generated class instead of magic one).

    As of now, nothing has really changed in Doctrine (to give a shot from the thread you mention) because of Doctrine 2 (which isn't native at all for sf 1.4) since the 1.2.x branch is almost dead (last release are 24/08/2010). Propel is still active, well really active, as you can see on github.

    I still work with Doctrine but I've learn a lot from Propel since few years. I've build some personal projects on Doctrine. As of today, I changed my mind, and if I have to start a new project I will do it using Propel.

    Few links: