PHP ORMs: Doctrine vs. Propel

前端 未结 10 2168
日久生厌
日久生厌 2020-12-02 05:57

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

相关标签:
10条回答
  • 2020-12-02 06:09

    The two references are somewhat outdated so you nevertheless cover some generalities, basically you'd have to evaluate your experience with the framework as such, a major drawback to doctrine is the inability to have an IDE that lets you auto-code in that propel is a winner, learning curves propel and doctrine are very different, it is easier to propel, if your project will need to manage complex data model uses doctrine, if you want to work quickly with an ORM which is best documented and find more support in Propel Internet uses, is much more mature and I believe that most used.

    http://propel.posterous.com/propel-141-is-out

    0 讨论(0)
  • 2020-12-02 06:10

    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.

    0 讨论(0)
  • 2020-12-02 06:12

    After using both of them for a number of years I prefer Propel 2 to Doctrine simply based on how you construct your query logic. Doctrine is as in depth as it can get and managing many aspects of it match that level of depth. Propel I feel has a more fluid and object driven way of building and managing the query interactions.

    For me this led to less code in the model and more structures around how logic can/will be processed. This resulted in just building out many interactions as common functionality. (After all 90% of what you will do with a database is just going to be some degree of crud operation.)

    In the end, both are powerful, manageable and will get the job done. My personal projects and interest use Propel ORM 2 and future projects, if still written in PHP will go that route.

    I've been using both on a daily basis for the past 3-4 years.

    0 讨论(0)
  • 2020-12-02 06:16

    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.

    0 讨论(0)
  • 2020-12-02 06:24

    It should be noted Doctrine 2 is currently in development released [ed] and functions almost completely different from the current stable version of Doctrine 1. It relies on the Data Mapper pattern instead of Active Record, and uses an 'entity manager' to handle persistence logic. When released it will bear closer resemblance to Java's Hibernate (Doctrine 1 is more like Rails' ActiveRecord).

    I've been developing with the alpha release of Doctrine 2, and must say it is heads and shoulders above Doctrine 1 (just my opinion, and I've never used Propel). Chances are good that the Doctrine community will move toward it when it's released.

    I would encourage you to check out Doctrine, but if you prefer the Active Record style that Propel and Doctrine use now, you might want to just stick with Propel.

    0 讨论(0)
  • 2020-12-02 06:25

    I'm not a user of PHP 5 non-framework ORM, but here's some good comparison posts (in case you haven't seen them yet):

    http://codeutopia.net/blog/2009/05/16/doctrine-vs-propel-2009-update/

    http://trac.symfony-project.org/wiki/ComparingPropelAndDoctrine

    Both conlusion favorite towards Doctrine as a newer generation of ORM for Symfony.

    0 讨论(0)
提交回复
热议问题