views:

289

answers:

3

Hi,

i am quite familiar with Smarty and recently decided to use Zend framework in implementation.

because i am aware of the various advantages of Smarty, i insisted my contractor to integrate Smarty in.

But now, i am questioning my assumptions.

Should I integrate Smarty in with Zend framework? simply because I am familiar with Smarty syntax?

I am also involved with the programming. I got the contractor to help in the architecture and with the prototype.

+3  A: 

A couple of years ago, we were using Smarty, saying it was "easier" for not-developpers (or, at least, not-PHP developpers) to integrate what they wanted in their HTML layout.

The thing is : instead of having to learn the basics of PHP, they had to learn Smarty -- and many didn't learn that well, should I add.


Now, Smarty is quite old, not well maintained nor anything... And Zend Framework expects people to use PHP in their views...

Using Smarty in the views of your project, based on ZF, would mean :

  • Developpers would have to learn Smarty -- and not only PHP+HTML
    • Even if you know Smarty, will you contractor know it well enough to use it properly ?
    • And what about your colleagues, or people you'll hire in the future ?
  • Problems with integrating it with ZF : even if you can use Smarty in your templates, will it be possible to use the full power or ZF ? Pluging, helpers, partials, and all that ?


An additionnal reason many of us said "use smarty", in the past, was to help with the separation of content and presentation ; but, as you are already using MVC in your ZF-based application, there's no need for smarty to do that : if you are following the ZF's guidelines, you are already separating those, even if not using Smarty.


Well, in the end, I would rather not use Smarty :

  • It's old and not well-maintained
  • It's not really useful in a ZF-based (with MVC) project
  • It might be hard to integrate in your project.
Pascal MARTIN
what about issues like caching? you said smarty is old and not well-maintained. i don't have any issues with old. PHP is not any younger than smarty anyway. i do have issues with whether it is well-maintained. what evidence do you have to support the claim that it is not well-maintained?
keisimone
Zend Framework provides several caching-related classes and features ; caching is probably more a matter of the application as a whole than a matter of just the view layer, in my opinion ;;; PHP is not young, but new versions are released quite often (bug-fixes, in PHP 5.2.x, for example ; or new features, with PHP 5.3 that was released last year) ;;; there are not that many new versions of smarty, I'd say : no version of the 2.x branch in almost one year (yeah, there are some beta of Smarty 3 ; curious to see how this will end ^^ )
Pascal MARTIN
+1  A: 

I would say these should be two separate questions:

  1. Should I use template engine or PHP as a template engine?

    The general purpose of the template engine is to separate view layer from the rest.

    Smarty implements V layer of the MVC. But Zend Framework already has it implemented quite well. So you do not add nothing new. There are filters, helpers as in Smarty. If you don't want to mix HTML and PHP at all, you may separate V in two and use markup Texitle for your view templates.

    Here's debate about whether or not to use template engine: http://fabien.potencier.org/article/34/templating-engines-in-php

  2. If I want to use PHP template engine, Are there any better solutions than Smarty now?

    Yes, eg. PHPTAL, which can easily be integrated into ZF as well.

The rest depends on you. If you are used to work with Smarty, or the project specification requires Smarty (eg. for backwards compatibility), there are no problems to use it in ZF at all.

takeshin
A: 

I did use smarty in my old project and in some projects now. I also did try to integrate it with zend. But as sir pascal martin said, zend already handle the view layer well. Although I was able to integrate it with zend, I had the following issues :

  • Zend_Form integration with smarty became an issue.
  • The view helpers and partials became a bit complex.
  • smarty learning curve
  • the resources(tpl etc) location

Also, in the end, I stick with the zend default view

Hanseh