Move from Propel to doctrine

Original Date: 2009-09-11

Big day today!

My plan is to dive into doctrine today by converting a small application. I have been using propel all the time and now it looks like I need to change something, because doctrine will be the path forward for symfony.

BTW, I’ll write this one in English, because it might help some people out there (and not only Germans…)

So, first stop:

The symfony and Doctrine Book

So I ran

./symfony configure:database --name=doctrine --class=sfDoctrineDatabase "mysql:host=localhost;dbname=dbname" user secret

to get the basic connection set up. Afterwards, I needed to clean some old Propel line removed from the database.yml

My Database is alread existing, so I can recreate the schema from the DB.

php symfony doctrine:build-schema

et voilĂ  – I have a subfolder doctrine with the schema.yml

Hmm, first question now: Where did the _attribute: { phpname: .. } go?

Looking at the schema, the big difference between propel and doctrine seems to be: doctrine specifies a tablename for a parent element called like the table, but propel specifies a phpname for a parent that IS the table…

In my example I have a mysql table called “plz” but the phpname was “Zip”.

So, doctrine created a classname “Plz:” with tableName: plz – I try to change “Plz:” into “Zip:” … keep your fingers crossed

The doc talks about multiple connectiosn and attributes now, I’ll skip that for now, got no clue what the attributes mean and I only need one connection.

BUILD!! Thats what I want to do!!!

I don’t want to erase the table, so I only

php symfony doctrine:build-model

and YES, as hoped, it created a “Zip.class.php”. COOL!

add some

php symfony doctrine:build-forms
php symfony doctrine:build-filters
php symfony doctrine:build-sql

and now we should be fine, right?

Leave a Reply