PHP ORMs: Doctrine vs. Propel PHP ORMs: Doctrine vs. Propel php php

PHP ORMs: Doctrine vs. Propel


I'd go with Doctrine. It seems to me that it is a much more active project and being the default ORM for symfony it is better supported (even though officially the ORMs are considered equal).

Furthermore I better like the way you work with queries (DQL instead of Criteria):

<?php// Propel$c = new Criteria();$c->add(ExamplePeer::ID, 20);$items = ExamplePeer::doSelectJoinFoobar($c);// Doctrine$items = Doctrine_Query::create()       ->from('Example e')       ->leftJoin('e.Foobar')       ->where('e.id = ?', 20)       ->execute();?>

(Doctrine's implementation is much more intuitive to me).

Also, I really prefer the way you manage relations in Doctrine.

I think this page from the Doctrine documentation is worth a read: http://www.doctrine-project.org/documentation/manual/1_2/en/introduction:doctrine-explained

To sum up: If I were starting a new project or had to choose between learning Doctrine and Propel I'd go for Doctrine any day.


I am biased, since I help a little bit on the next release of Propel, but you must consider that Propel was indeed the first ORM available, then lagged a bit when Doctrine got created, but now has active development again. Symfony 1.3/1.4 comes with Propel 1.4, where most comparisons stop at Propel 1.3. Also, the next release of Propel (1.5) will contain a lot of improvements, especially in the creation of you Criteria (resulting in less code for you to write).

I like Propel because it seems to be less complex than Doctrine: most code is in the few generated classes, whereas Doctrine has split up the functionality in lots of classes. I like to have a good understanding of the libraries I am using (not too much "magic"), but of course, I have more experience with Propel, so maybe Doctrine is not so complicated behind the scenes. Some say Propel is faster, but you should check this for yourself, and consider whether this outweighs other differences.

Maybe you should also consider the availability of Symfony plugins for the different frameworks. I believe Propel has an advantage here, but I don't know how many of the listed plugins are still up-to-date with the latest version of Symfony.


It comes down to personal preference.I use Propel because (among other things) I like the fact that everything has its own concrete getter & setter method. In Doctrine, this is not the case.

Propel:

$person->setName('Derek');echo $person->getName();

Doctrine:

$person->name = 'Derek';echo $person->name;

The reason I like having getters & setters is that I can put all kinds of logic in them, if I need to. But that's just my personal preference.

I should also add that although Propel was slow-moving in the past, it is now under active development again. It has released several new versions in the past few months. The most recent version of Propel includes a "fluent query interface" similar to Doctrine's, so you don't have to use Criteria anymore if you don't want to.