phpormsymfony1doctrinepropel

PHP ORMs: Doctrine vs. Propel


I'm starting a new project with symfony which is readily integrated with Doctrine and Propel, but I of course need to make a choice.... I was wondering if more experienced people out there have general pros and/or cons for going with either of these two?


Solution

  • 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.