Doctrine ORM and Zend Framework, sample project to get you started (with sample database)
10 Comments 20th APR 2009 | Posted by Branko Ajzele in Zend

I’ve created a sample project for those of you interested in working with Doctrine ORM and Zend Framework (my favorite toys in last few weeks). All you need to get it up n running is a download of Doctrine ORM and Zend Framework.
Project is set for auto loading both Zend and Doctrine Frameworks so all you need to do is to instantiate
-Also, below you can see few screenshots of the sample code I implemented. Also, I provide you with the .sql dump (doctrinesql) file that goes with this project. Note the use of InnoDB engine in database. Since Doctrine comes with this cool hasOne, hasMany relation mappings, you can use bunch of cool stuff to easily do various actions on database once you get familiar with Doctrine. Although MyISAM engine is somewhat faster than InnoDB, without second thoughts I choose InnoDB due to foreign keys features.
Download project files:
doctrinesql
doctrine_example_project (doctrine orm and zend framework)
To post code in comments, place your code inside [code] and [/code] tags.

























April 22nd, 2009 at 2:33
Great article. Everything is easy to understand and it’s a meaningful example.
How would you add a new Article without knowing how many the user had?
Could you simply reference it as:
$user->Article[]->title = “Unknown number of articles”;
etc…
I’d be interested in seeing a version of your Zend_Auth entry redone using Doctrine.
April 22nd, 2009 at 4:15
I played around with your example and figured out a solution that answers my question.
You can do something like:
$article = new Article();
$article->title=”whatever”;
$article->content=”whatever”;
$user->Article[] = $article;
$user->save();
May 27th, 2009 at 8:20
Hi, Have you tried this in a ZF1.8 enviroment? where would you put the Doctrine_Manager::Connection call in the new bootstrap class architecture?
July 1st, 2009 at 8:48
Hi Will,
In Zf 1.8 just create a resource, named for exemple “Doctrine”, and dont foreget to bootstrap it at initialization.
Hope it will work for you.
August 17th, 2009 at 16:36
Will: take a look at http://www.danceric.net/2009/06/06/doctrine-orm-and-zend-framework/
Should contain what you need I think
August 26th, 2009 at 22:57
Wow, are you using Eclipse, ZF and Navicat on the Mac? If you’re running MAMP we have identical dev environments.
January 28th, 2010 at 18:29
Hy,
I have downloded ur stuff, buts it download files with no extensions, how can i use these for learning.
Actually I am a New baby in ZF and lloking for help in configuration of ZF and atleast development of small application like the one u mentioned here, but i am not able to proceed, got stuck in, will u please help me out in this regard,
I am keenly waiting fr ur rep, as ur above tutorial lokking helpful .
can u plese send me this whole small working application in Zip format, so i just unzip and execute the sql to get it working.
thnx in advance fr help
Regards,
March 19th, 2010 at 12:57
nice example. very helpfull for a beginner. thanks
June 9th, 2010 at 11:04
Hi,
Thanks for the great article. Could you please tell me what piece of software there is on the second screenshot?
I’m also a Mac OS X user and that looks quite interesting.
Cheers.
June 24th, 2010 at 15:09
Hi,
thank you for this great article. It made me finally start using Doctrine and I haven’t regretted it. I can’t thank you enough for that.
BTW: I’ve found ORM Designer (http://www.orm-designer.com/) for Doctrine which helped me a lot. It’s still under heavy development, but already deadly useful.