You're in the army now
Posts tagged application
translate($this)
Nov 26th
So I needed to set up a translatable website and thought I would re-visit the way I use the translate component from the Zend framework. Previously I set up the translate component and would then create a plugin to handle the language change which I would trigger by changing a session variable.
Although this works I tended to feel it was a bit slap dash and that there must be a more efficient and useful way of utilising the component without the need to utilise a plugin.
So having had a nose around the net I decided that I wanted to make the language URL driven. I also wanted to steer away from using a subdomain to drive the language selection (i.e. en.website.com/pagename) and wanted it to be a part of the url (i.e. website.com/en/pagename) as this was more in keeping of the style of site I like to use.
So with a little tweaking code and utilising both the Locale, Translate and Router Resources here is how I did it.
More >
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.

