How Do You Zend_View? I'll Show You Mine...

Posted in PHP and Zend Framework on Sunday, the 25th of October, 2009.

An interesting design decision made by the Zend Framework team was, well, not to make too many decisions about how the View portion of a Zend Framework MVC application should be implemented. You can use plain PHP to generate markup, use a templating library such as Smarty or Savant, or go your own way entirely. At work we've used both Wall4PHP, and subsequently a custom component-based solution, for example.

The flexibility is great then, but with freedom comes responsibility. Perhaps coincidentally, view scripts tend to be the part of a ZF app that attract the most cruft, the most untestable code, and the most mingling of concerns (though controllers certainly give them a run for their money).

Since someone recently asked, I'll show how I've implemented views on I don't claim that the approach is awesome, or even suitable for every case, but it seems to work for me. In return I'd very much like to hear or see how others implement their Zend_Views.


Posted by Ciaran McNulty on Monday, the 26th of October, 2009.

Really interesting stuff (and thanks for the namecheck).

If you're finding you're doing a lot of includes of headers, footers and so on in your views it's really worth looking at Zend_Layout.

Posted by Russell on Monday, the 26th of October, 2009.

At work we use Smarty, which I find tedious and badly documented. Interestingly I was the only one who was against using it in our team though.

Enter your comment: