NinjaCipher:-*-:ro60

Zend Framework MVC with Smarty

So in my recent work on Kitchenkungfu I’ve been doing allot of work on marrying Zend Framework’s MVC with Smarty templates handling the view layer.
For those of you out there that aren’t familiar with Smarty its a very nicely architected php template engine. People love it because its simple for people with little programming knowledge to work with, nicely encapsulates display logic enforcing controller/view separation by convention and best of all (which is what attracted me) is it’s fast. Smarty actually goes through your template code and compiles it into php so that it doesn’t have to be parsed over and over again. It’s also got its own caching built in which is a big speed gain as well.

After doing a good deal of digging I was able to find a few different blog posts and articles outlining the steps. This entry from the zend manual is a good start for anyone who is interested.

Basically the route they suggest is implementing the Zend_View_Interface functions and creating a Zend_View compatible wrapper around your Smarty object. Once you do that it’s pretty much plug and play. The example in the manual is pretty good but it def leaves some room for improvement so you will have to hack it a bit to take full advantage of Smarty’s tool set.

So after a few hours of head scratching and fiddling I now have a working ZF MVC with Smarty views. I feel good about it and just read on another blog that Flickr uses Smarty for their display layer too which is encouraging. Check back in a few month and I’ll let you know how it’s holding up. Fingers crossed…

Del.icio.us Digg BlinkList Furl Ma.gnolia Reddit Spurl

Leave a Reply

You must be logged in to post a comment.