Zend MVC plus Smarty

I’ve been playing with both Smarty and MVC. I can’t help but feel that having both Smarty and MVC is a bit redundant. Smarty was developed so that people with little to no programming experience can be involved in the designing process through the use of templates. MVC is known as Model, View, and Controller. The whole point of the system is to separate the components behind a major web application such that people with different backgrounds can come together and build an application. The model contains the business logic; it is the layer that accesses the database and prepares the data. The controller is the component that handles the parameters and figure out what kind of data it needs and where which views to render in order to achieve the result desired. The view is the component that contains the design for the application. It’s designed in such a way that even a person with no programming experience can code and develop.

It seems in that regard, Smarty and MVC are achieving the same thing. I know caching is a big benefit provided by Smarty, but you’ll find that most MVC frameworks have caching solutions as well.

The model I was coding employed the Table Data Gateway pattern, the resulting object was then feed into the Zend Paginator object, which is then supposed to be fed into a view. The object takes care of every aspect of pagination. Smarty also has a means of paginating, but it then in order for it to perform pagination, requires SQL statements thereby bypassing the model layer. Even if you attempt to pass the Zend Paginator object directly into Smarty, the iterator for the Zend Paginator is completely useless due to Smarty’s insistence on using arrays instead of objects. Although it’s possible that more recent versions of Smarty might’ve corrected this error, but this is one programmer who would have rather worked with Zend MVC instead of Smarty plus Zend MVC.

Leave a comment

Your email address will not be published.