PHP ORMs: Doctrine vs. Propel

前端 未结 10 2174
日久生厌
日久生厌 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:35

    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.

提交回复
热议问题