I have immersed myself in the Zend Framework for the past 30 days; spending that time learning the ins-and-outs. I’ve started writing my first application utilizing the framework, and must say so far I am pretty happy with it’s flexibility. The learning curve is a bit higher than I had expected, but I attribute this to the vast amount of complexity involved in trying to make the application flexible.
In the development of the front end of my application I found myself at dilemma to Smarty or not to Smarty (or a derivative there of). I started researching the history of Smarty and other types of similar formated coding standards if you will, to better understand the real concept for using such a format. The classic and consistent argument is separation of application code from display code, in this instance the separation of php from html code. Which only brought forth further questions; from my perspective with a properly designed MVC application utilizing models to translate object code to visual representations, Smarty did not appear to be needed.
A quick and rough example. Your application returns you an array of data; lets say
$data = array('firstname'=>'nick', 'lastname' => 'white');
If I wanted to display the name in a table within my html, traditionally you would begin your html table tags, foreach loop through the array adding your table data tags as needed and end your php code and respectively your table.
Using what I consider to be a properly formated MVC environment, I would apply a data model within the action controller of my application, formatting the “mynametable” prior to the rendering layer and assigning the model to a variable. Using this layout within my application allows me to need no more than the standard echo variablename to display the table and it’s data.
So I guess my question is, if you utilize your model’s within your MVC environment to handle display data structure, do you really need a Smarty system to display the data….
Leave comments… I want to see your thoughts.