On Wed, Mar 25, 2009 at 5:31 PM, Andrei Iarus <[email protected]> wrote:
> Hello there,
>
> A lot have been discussed, but anyway it is still difficult to decide. A
> project is to be developed, and more persons will have to work at it. Those
> persons will have some experience in ZF and probably also in Smarty. The
> problem is: what are the advantages and disadvantages of using ZF Template
> Engine vs. Smarty. How much of you use Smarty? Why do you prefer
> Smart/Zend_View?
>
> I see as advatages for Zend_View:
> 1. Some packages from ZF use Zend_View (Zend Layout, Zend Form, other
> examples?), so if we would use Smarty and use those packages (which we'll
> do), we will need to extend the abstract classes. Also it is possible that
> new comming features will use Zend_View.

For example Zend_Form can render straight HTML, so there's no need to
extend the classes. You just 'echo' your form:

$form = new My_Form; (My_Form extends Zend_Form etc.)
echo $form; // renders the complete form

> 2. Easier to learn than Smarty (right?), as it is clean PHP.

Generally, no. It's not easier to learn and also not clean PHP. Smarty
has its own markup therefor adds another layer on top of PHP and HTML.
I have my doubts that this is easier to learn than a bunch of PHP
commands to do some basic loops and echo some variables. That's pretty
much all you should do in a view anyway.

If you are concerned about your designer you could always wrap more
complex code into a Zend_View_Helper (I think the equivalent to a
modifier/insert in Smarty) and have them "echo" this, e.g.: echo
$this->MyHelper();

I think the biggest advantage of Zend_View is that it's so integrated
into many components, the API is pretty clean and it's all PHP5 code.
The last bit is kind of important since 5.3 is literally around the
corner. ;-)

I think Smarty currently maintains BC with PHP4 -- I could be wrong though.

> As an advantage for Smarty:
> 1. It is more popular than Zend_View (right?) .

Depends also! If you been doing websites for 10 years, maybe. ;-) You
can argue either way. If someone hasn't done any ZF work yet and
neither did any Smarty, I'd call it: double the pleasure. ;-) (Irony!)

> 2. It has those built-in common-used functions (ex. excaping functions).

There's view helpers and pretty comprehensive chain of validators and
filters that achieve the same/better results. ;-) The most basic is
<?php echo $this->escape($this->foo); ?> in your view file.

> 3. One can say it is easier/more pleasant to develop in Smarty (it is for a
> long time a stand-alone V(iew) component (from MVC) )

I disagree here. I've used Smart extensively. And I don't mean to
offend anyone (especially all the people who worked on Smarty over the
years) because I really loved using it back then. If I used it in a ZF
app with MVC now, I would double the view layer basically and add more
to the code base than necessary.

The code gets more complex for now reason. Everything you want from
Smarty is available in the ZF -- cache, etc. too. All, sans the weird
{foreach} and {section} syntax which I still need to look up today.
;-) This in the end makes it harder for other developers to dive into
it.

The bottom-line is that it's a personal preference too. I generally
try to avoid PHP4 code nowadays and I'm also not on top of the recent
Smarty developments (I noticed that they are releasing new versions
though).

Hope that helps!

Cheers,
Till

> What would you decide if you were in my place?
>
> Thank you very much in advance.
>

Reply via email to