Is this a good idea to use Yii Framework with Doctrine 2 ORM?

3k views Asked by At

I love Yii Framework, it works fast, it's pretty cool and easy to develop with. But now I have a problem - I am going to develop Learning Managment System with difficult domain logic and it's not good for me to use Active Record from Yii for my models, it would be better to separate mapping and domain logic.

So I decided to use Doctrine 2 ORM. It's pretty cool too, I liked it when previously I worked with it. But I think it's enough big for not so big Yii Framework.

the main problems are

1) I need some kind of ORM for separate domain logic and mapping. Are there any alternatives for Doctrine 2 ORM?

2) I need good framework to work with this ORM. Is Yii well-suited to use it with Doctrine 2 ORM? Will it lose its benefits when I will use such big and not so fast ORM as Doctrine 2? Maybe it would be better to use Symfony 2 framework to work with Doctrine 2 ORM because they are natively in couple

Thanks

2

There are 2 answers

2
Elango Mani On

RedBeanPHP is an easy to use open source object relational mapping (ORM) software for Yii framework. Created by Gabor de Mooij in the Netherlands, it is licensed under GPL and New BSD.

RedBeanPHP is used as the database abstraction layer for your Application.

Learn more about RedBeanPHP here: http://www.redbeanphp.com

0
Cherif BOUCHELAGHEM On

If you have complicated domain model (not just CRUD) Doctrine2 is fine and it is framework ignostic so you can use it with yii2 and use Yii2 just for the delivery mechanism (Web,Console or others) just note that you have to make data providers like those pre-existed in yii (Maybe RepositoryDataProvider or QueryObjectDataProvider), but I think using a big ORM for reading data especialy for reporting (Grids, lists charts etc) is not a good idea so I can use doctrine for writing (when the domain logic is applied) and Yii2 Dbal for reading because the Yii2 db infrastructure is realy fast