tags: database dev doctrine orm php
30 Oct 2008 19:48
A few days ago, I found Doctrine Project which is an object-relational mapping (ORM) solution for PHP. It seems really powerful and actually very similar to Wikidot DB Layer (especially one in Wikidot 2).
Doctrine is a really cool project and has features of:
- Wikidot DB
- Zend Framework DB
- Hibernate (ORM for Java)
- Ruby on Rails DB
Let's start from the beginning of the list.
Doctrine is most similar to Wikidot DB, because both:
- are ORM implementations for PHP
- use abstract (non-PHP, non-SQL) data definition language
- for Wikidot it's XML-based format
- for Doctrine it's YAML-based one
It's similar to Zend Framework DB, because of:
- using magic PHP methods for accessing objects properties
Hibernate and Doctrine shares:
- completeness of the DB layer
- higher abstraction than other DB layers
Ruby On Rails concepts in Doctrine:
- using YAML as a model definition language
- independence of database engine
Example of model definition:
Doctrine comes with a CLI tool, that offers the following things:
Doctrine Command Line Interface
The tool can be used to generate PHP files from YAML files, generate SQL files (for given DB engine), drop and create the database and more.
The dql seems to be an interesting option. Doctrine supplies its own backend-independent SQL-like language for querying and updating the DB. These operations can be done with the dql option. Although I haven't tested it yet, it seems perfect for some cronjobs or other automatic tasks that don't need to be coded in PHP.
Now, I'm converting my nuclear project — opiwo.com (bet a beer in Polish) to Doctrine ORM (from Zend Framework's one) to see how it works in reality. The project uses also other nice technologies like JSON-RPC.
Please forgive me I'm now quite excited about the Doctrine. It's just how I react to some really cool (well-designed) things. I hope it's really that cool :).