Well I must say that in first time I have heard about ORM when started to use symfony more than 5 years ago (until that time I only used direct db queries). So I realized that there are 2 most powerful PHP ORM’s: Doctrine and Propel. And they are both moving forward pretty well and adding new cool features. Actually once I also used Pear DB_DataObject but I don’t think experience was really fun, at that moment there was not really much documentation about that ORM so I had to learn everything from sources.
So now I decided to figure out if there are any other ORMs out there? Why you may ask yourself the same question? Lets say you have some big working system with old code and want to make it better and add ORM to it, which one to use? You may want to investigate all options before stick with Propel or Doctrine. These 2 ORMs are good but also brings lot of features which you most probably wont need to use (and it affects performance!).
So for the beginning I decided to realize which features should have ORM:
- Mapping Classes To Tables
- CRUD Functionality
- Hydrating Entities
- Session Level Cache
- Executing Custom Queries
So I agree, these ones are good for the beginning. But also when you want to use ORM for existing project it’s important to make sure you wont need synchronize config files with the DB schema (so ORM has to read the structure and primary keys directly from the tables).
Here are some interesting articles which give you an idea about features ORM must have and the way ORM may work:
http://ayende.com/Blog/archive/2006/05/12/25ReasonsNotToWriteYourOwnObjectRelationalMapper.aspx
http://davybrion.com/blog/2009/08/build-your-own-data-access-layer-series/
http://www.derivante.com/2009/05/14/php-activerecord-with-php-53/
Now lets quickly go through the ORMs list (worth to mention that I did not really pickup the best one for myself). The list has 2 sections – actual ORMs in the wild and ORMs which are built into frameworks (it means that most probably you’ll have to use whole framework to get access to best ORM features which is sucks)
- ADODB Active Record
- CoughPHP
- DaBase
- Doctrine
- dOrm
- LightOrm
- Outlet
- ORMer
- PHP-ActiveRecord, An open source ORM library for PHP5.3 based on the ActiveRecord pattern.
- PdoMap, inspired by Hibernate
- phpDataMapper
- PHPLinq
- phpersistence
- phpORM
- Pork.dbObject
- Porte
- Propel, inspired by Apache Torque
- RedBean
- Repose
- Rocks
- Redbean, ORM layer for PHP 5 that creates and maintains tables on the fly
- Torpor
p.s. we are planning to add links for ORMs in this list gradually
Now the ones which are built into frameworks
- Axon ORM from Fat-Free framework, supports also Mongo DB mapper
- CakePHP based on database introspection. No class extending or code generation
- CIEXtended based on CodeIgniter
- Kohana ORM
- QCubed
- Qcodo ORM and framework for PHP5
- PHP Faces Framework
- PMO
- Solar Solar_Sql_Model
- Xyster Xyster’s ORM
- Zend Zend_Db_Mapper
So the list is not small and I was really impressed by the fact that there is such bug ORMarium.
Here worth to mention also about new mongodb ODM (object document manager) project from author of Doctrine which is NoSQL alternative of ORM.
And finally when we was already working on this article we’ve got new sponsor which is ORM Designer, so wanted to mention about them here as well as they provide graphical way to work with famous php ORMs.
Have a great day!
2 replies on “Is there life out there (or what is your ideal ORM for PHP)?”
Is There Life…
[…] me question? Lets say you have some big working system with old code and want to make it better and […]…
yeah!, doctrine rocks
and with mongodb, you can use mondongo ODM and his symfony plugin sfMondongoPlugin
See more in http://mondongo.es/