Well it’s looking like Doctrine is the heavy weight data mapping solution of the lot. Zend Framework was often criticized for having no serious Model methods. Models was just sort of where you put your nuts and bolts database code. Some folks like the structure of the Active Record model that you see in Rails some other PHP frameworks. Sure it makes it dead easy when your tables map pretty straightforwardly onto your objects but makes it harder to have complex objects involving many tables. Zend was working on their own Zend_Entity package to remedy this, but they have abandoned it in favor of integrating Doctrine. The Zend Roadmap for the future calls for tight integration of Doctrine with the framework, so there will probably be some additional automatic linkage, with the view to the framework user’s code being smaller. But both ZF 2.0 and Doctrine 2.? are for PHP5.3, which is some time down the pike for ordinary folks. On the ZF Wiki there is a proposal to integrate current versions, at least to some extent. The symfony camp are hollering that Doctrine automatically “just works” in symfony, and that’s great. But for now you do have to do a little work to integrate it with ZF.
So first thing to do is get my head around Doctrine. The manual for it spends a lot of time going through the various things you can specify, and shows you how the PHP code is isomorphic to a yaml specification. This is fairly straightforward. The DQL seems straightforward too. You just have to remember that you *PRECONFIGURE* all the ON’s for relational table joins so you just have to tell it what you want. And then it is a matter of getting fluent using all the methods it defines.
I started by having a look at the Doctrine Sandbox, and that worked for me pretty easily. I then advanced to the doctrine tutorial, and that also worked without a hitch. But now we have to confront the 800 lb. gorilla in the room: Zend Framework
The problem with integrating it with Zend Framework seems to be autoloading and how to best integrate the whole thing with the bootstrapper. I’ve collected a bunch of links related to this for now, and may eventually get it together enough to publish my own solution. But here is what I have: I’m trying to extract the essence of this so that I can have my own way I feel comfortable with and not slavishly copy any of these. In the interest of sharing, I’ll just post the links here, then when I’ve digested this rather large glom, I’ll comment. Feel free to mention any more that you know in the comments:
- Seminal post from ruben
- Ruben’s ideas updated for 1.8 tools
- WeieroPhinney’s post on this subject
- http://morecowbell.net.au/2009/11/zend-framework-and-doctrine-part-1/
- Joe Gornick’s best practices
- giorgio soroni’s first date
- Juozas Kaziukenas contributions (Has a download archive instead of inline code.
Hi, I’m writing about this right now (2 parts done), syou might want to check it out: http://dev.juokaz.com/php/zend-framework-and-doctrine-part-1
A quick google search took me to a Question posted on StackOverflow about Doctrine Memory Usage. The concerned OP was asking if he had a server misconfiguration or if this was normal for Doctrine to be using so much memory for a simple query. He posted a 4MB difference in Peak Memory Usage between the start of the request before the Doctrine Query was executed and after the Doctrine Query was executed. After reading that, I was a little nervous.
Thanks Juozas, I have updated the post to include a link to your work!
FYI, the link above to my site is broken.
Here’s the real address – http://morecowbell.net.au/2009/11/zend-framework-and-doctrine-part-1/
Sorry Phil, that must have been a late nite edit. I fixed it. I am a little concerned about the memory usage issues.
got it, i will try to do it.
Nice post but Please, write something about sub queries in Doctrine.thanks
Ill be honest some of this is over my head… But I do appreciate all the links you provided. I hope they will help clear things up for me.
Thanks
wow really great information on zend framework. i need some more information on Doctrine.
I appreciate your work. nice links thanks for sharing them too.
Another useful method to take a look at is Doctrine::compile()
doctrine-project.org/Doctrine/1_1#method_compile (Or the Doctrine_Compiler class).
You have shared very nice information about Zend Framework and Doctrine. I have not more knowledge about Doctrine. Can you provide more information about it?
Good post now i want to learn ZF. I also have noticed an increase in speed with ZF after following the manual performance guide.
And even though its still a bit slow i think all the benefits you get by developing with ZF makes up for the speed.
So am I. Also would be thankful for some more information on Doctrine!
magic story very thanks Pornhub
441
thanks for assisting us out