Is there any advantages to integrate Smarty with Zend?
i am quite fa开发者_C百科miliar 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.
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.
I would say these should be two separate questions:
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
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.
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
As a front end developer I regularly work with smarty and find that the additional modifiers and plugins save me a lot of time:
Varialbe Modifiers Built in PLugins
Also Smarty has its own caching that caches the smarty tags into native PHP. So no problem with extra processing with the cache templates.
Smarty 3 has been updated recently and has been improved.
精彩评论