You're in the army now
Posts tagged Db
Zend In- Doctrine -ation
Nov 26th
So I’ve been using The framework and Zend_Db for a long tine now and I’m happy using it for some of the simpler projects I have had to do. However I have had a requirement to use an ORM.
I was looking forward to using the upcoming Entity component that was being built but after reading this at nabble. I decided that it was time to investigate using Doctrine.
So after having a little play and reading all the tutorials/guides I could find I had a go @ integrating Doctrine into my latest project base.
So far no single guide/tutorial has gotten it 100% right for me. I was wanting to make it a seamless integration using the frameworks application component.
So here goes my amalgamation of quite a few guides to try and give a more complete picture. My apologies if I forget to attribute any bits of code I may have borrowed/adapted. Let me know and I will add you in.
Some things to make you aware of
- First I built this with 1.9.5 of the framework. I havent tried it with any earlier versions but it should work pretty much the same.
- I used Doctrine 1.2. It is still in beta on their website t the time of writing. But having had a nose through their blog I can see that they are on the verge of releasing it as stable. So by the time you read this it will most likely be stable. My reasoning for this is that 1.2 appears to handle the building of models a lot better than earlier versions.
- In order to get all the features I wanted to use working I had to adjust part of the Doctrine library. As part of the way I wanted to use doctrine was to build models automatically from yaml files. Unfortunately Doctrine appears to be reliant upon using a component from the symfony framework. Not that I’m knocking Symfony but I much prefer Zend and as such have no desire to use Symfony. That said.. for the sake of speed I downloaded Symfony and copied the 4 files I needed. I’ll cover what I did bit later. I have logged this as a bug/task on Doctrines bug tracker (http://www.doctrine-project.org/jira/browse/DC-288) hopefully they will spot it and apply a suitable fix/inclusion.
- All my code is part of my own library which called Zucchi. All of my code is available in my project base in my subversion repository here. feel free to make use of it.
Sgt Zend
Jan 26th
I’m a really big enthusiast for the Zend Framework. In my opinion its got to be one of the simplest yet most versatile framework that I have come across in all my time as a programmer. Rarely have I seen a framework where I can get a whole MVC style site up and running in less than 30 Min’s (a very very basic site mind).
So what can the framework do?
Well its most useful and what i would call primary function is to enable you to build MVC style web applications, and it does this with ease.
Among the other libraries there are quite a few that can be use both in conjunction with the framework or as a stand alone component. The most useful of
these i find if the Zend_Db. A fully featured database abstraction layer allowing connection to a wide variety of data source such as DB2, MySQLi, Oracle and a fair few PDO connectors. Its a very clever piece of coding that allows standardised access to via a programmatic object orientated method.
Another of my personal favorites is the Zend_Form. It instantly takes the hassle out of writing forms by giving a php based method of generating a for dynamically. This coupled with the Zend_Config library give you a way to instantlybuild forms that are not embedded in HTML templates making it easy to manipulate them as you need. I’m woking on an interface that will hopfully give a point and click method of building forms and generating the appropriate config files that can then be fired straight into Zend_Form. If I ever manage to get around to finishing it I will post it here.
A couple of other components worth looking at are Zend_Auth and Zend_Acl , even though they are separate components I always tend to think of them in the same context. Mainly because I just thing its daft to create a secure loging with the Auth component and not include an ACL to manage the users. The Auth is extremely versatile, allowing you to connect to a number of diffferent platforms to validate your Authentication. I tend to use it mainly with a database connection through the Zend_Db connector, but it will connect justas easily with an LDAP or active directory as it will a hash file on the server.
The ACL is remarkably simple. usiing a very simple tree system for resources, roles and rights. It really is as simple as saying “Bob can read this page”. That said you can also make it extremely complex just by expanding out on it.
The framework also sports a very elegant caching system in the guise of Zend_Cache. With a large number of frontend and backend platforms available it can make light work of any site that may become a resource hog. This is a definate must for any web application that you build.
So thats my intro to the framework. If your interested in learning more I would strongly suggest heading over to the frameworks website (http://framework.zend.com) as it has an excellent reference guide that breaks down each and every conponent along with a very very concise quickstart guide that will tell you how to get a hello world example up and running in no time at all.

