Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use Doctrine instead of CakePHP's standard database ORM?

I've about to start work on a new web project using CakePHP 2.2, having mostly worked with Zend Framework 1 previously.

On first look, I really like the way CakePHP handles models and the underlying database tables, especially with regard to getting one-to-many and many-to-many relationships setup quickly with the minimum of fuss. It seems, quite frankly, a breath of fresh air compared to how I used to do things in Zend Framework.

However, over the last few years whilst using Zend Framework, I had looked at using Doctrine to provide the model relationships that ZF was rather clumsy at doing. Doctrine looked to me to be very powerful and flexible.

So now I am wondering, before I get too deep into my new CakePHP project, should I still consider using Doctrine with my new choice of framework? What advantages and disadvantages does Doctrine bring to the table (no pun intended!) compared to CakePHP's built-in ORM and database functionality?

like image 343
monkeyhybrid Avatar asked Sep 19 '12 20:09

monkeyhybrid


1 Answers

CakePHP works best if used as a whole. In your specific case though you can use Doctrine instead of Cake's ORM if you like but you will lose lot of features of cake. For eg. the FormHelper does lot of things "magically" like guessing proper input type for fields etc. using the model's schema, automatically showing error message below appropriate fields in forms when validation fails, etc.

As you commented you don't have much experience with Doctrine either so I would suggest sticking to CakePHP's ORM and look for option only if you find it inadequate for your needs.

like image 120
ADmad Avatar answered Oct 25 '22 15:10

ADmad