Thursday, November 13, 2008

Starting with Doctrine ORM

Preparing myself to switch from Symfony 1.0 to Symfony 1.2 as my default framework, I started to read the Doctrine documentation to get familiar with it - I used Propel as default ORM in Symfony before. I bet I am not the only one in the community...

I have not yet reached the end but I cannot resist to share my feeling about this amazing piece of code. As a symfony developer I do not need to read all Doctrine documentation since a lot of things are automatically generated thanks to the tied integration between the 2 frameworks.

Since I was used to Propel behaviors and installed in most of my projects some pretty standard plugins to create behaviors such as: Slug, Versionning, Nested set, Tags... I came to realize that most of those plugins are actually part of Doctrine out-0f-the-box! Just an example from the documentation to create a simple wiki with i18n (internationalization), slug, search and versionning (it could be apply as well to a CMS or whatever you wants):

fields: [title, content]
fields: [title, content]
fields: [title, content]
fields: [title]
title: string(255)
content: string
Even thought I will propably prefered to use Lucene for the search part, all the rest is amazing: just a few lines in your schema.yml files and "hop!" you got everything ready (I don't even mentioned that you actually nest those behaviors here...). They even have a "Geographical" behavior that I definitively want to test later.
It is also more readable and make more sens - to me at least- to define behaviors in the schema.yml file rather than in each class of the model.

There is no doubt, Doctrine is a good move! And remember: I am just talking about behaviors here, there are much more things in the documentation...I still need to go to read them...

1 comment:

  1. I actually enjoyed reading through this posting.Many thanks.

    Symfony Development