Comments for Smarty PHP template engine

30 Sep 2002 08:17 timparkin

Re: What actual benefit do I get?
Hi,

The benefits of using smarty are that you get a *structured* system for templating that is standardised. If you use PHP, you still need to develop your own system for including sub elements and setting variable scope and you also end up with having to use <?php print 'web design leeds (www.pollenation.net); ?> when you want to include small sections. This would be a lot cleaner if it is set inside the php and included in the page as a variable {$webAddress}. On top of this the argument about speed is a stupid one that most people really need to get their heads around. we are talking milliseconds for page build when the average delivery time is seconds. Thats a 1000x difference. Even if you are running a VERY busy site, you are unlikely to get more than 10 simultaneous hits on your server at once. This means that at the worst your pages will be maybe 0.2s slower through the use of templating and typically about 0.02s.

As an example of speed, our website www.pollenation.net (http://www.pollenation.net) is built using smarty and we've tested it at 100 hits per second and it handles it fine. And this is with mod rewrite overhead and an application server in front of it and database abstraction etc etc.

11 Jul 2002 18:01 mohrt

Re: What actual benefit do I get?

> Hi there.
>
> I testet Smarty and had a look at the
> documentation. Now, however, there
> remain some questions.
>
> The syntax within Smarty templates is
> similar to the common PHP syntax. I
> output a variable using the notation
> {$MyVar} - in a PHP script, I would
> write <?=$MyVar?>. Then I have
> modifiers and plugins like
> "upper" doing tasks that are
> already covered by native PHP funktions
> (e/g strtoupper()) - yet the Smarty
> stuff is less flexible in use (and
> probably slower since PHP functions are
> called via the "template engine
> detour"). All in all, any template
> designer will have to dig into the
> Smarty syntax and learn it before they
> can create working templates.
>
> If I got it right, the compilation of
> templates means that files are
> translated from the "Smarty
> language" to PHP, meaning of course
> that these compiled scripts will be
> parsed again by the PHP parser on
> request.
> Nothing against that - but when the
> syntax is so similar, why do we need the
> Smarty templates in the first place?
> So from my point of view this template
> engine just looks a little like a big
> wrapper that does things you could do
> with plain PHP - and yet it is not much
> easier to use than PHP itself.
>
> With those drawbacks - tpl designer
> having to learn a "language"
> similar to real scripting, a lot of
> overhead code on every request and
> nothing really you couldn't achieve with
> plain PHP code just as easily - what do
> I get out of using Smarty?

The benefits are countless, but one good point is the separation of application logic from presentation logic. The application programmer can change application logic without worrying about messing up the presentation of content, and a template designer can modify the presentation without breaking application logic.

06 Jul 2002 21:26 Yaro

Re: What actual benefit do I get?

> The syntax within Smarty templates is
> similar to the common PHP syntax. I
> output a variable using the notation
> {$MyVar} - in a PHP script, I would
> write <?=$MyVar?>. Then I have
> modifiers and plugins like
> "upper" doing tasks that are
> already covered by native PHP funktions
> (e/g strtoupper()) - yet the Smarty
> stuff is less flexible in use (and
> probably slower since PHP functions are
> called via the "template engine
> detour"). All in all, any template
> designer will have to dig into the
> Smarty syntax and learn it before they
> can create working templates.
>
> If I got it right, the compilation of
> templates means that files are
> translated from the "Smarty
> language" to PHP, meaning of course
> that these compiled scripts will be
> parsed again by the PHP parser on
> request.
> Nothing against that - but when the
> syntax is so similar, why do we need the
> Smarty templates in the first place?
> So from my point of view this template
> engine just looks a little like a big
> wrapper that does things you could do
> with plain PHP - and yet it is not much
> easier to use than PHP itself.
>
> With those drawbacks - tpl designer
> having to learn a "language"
> similar to real scripting, a lot of
> overhead code on every request and
> nothing really you couldn't achieve with
> plain PHP code just as easily - what do
> I get out of using Smarty?


You even get no close to the idea and technology of Smarty. Smarty doesn't parse already compiled scripts! They are pure PHP which executed as fast as other PHP scripts. So Smarty syntax give you a Power of flexibility, whean you want to make "every day task" in one line of template code. Smarty is the best thing which I use in my projects.

08 Jun 2002 06:33 streetjesus

What actual benefit do I get?
Hi there.

I testet Smarty and had a look at the documentation. Now, however, there remain some questions.

The syntax within Smarty templates is similar to the common PHP syntax. I output a variable using the notation {$MyVar} - in a PHP script, I would write <?=$MyVar?>. Then I have modifiers and plugins like "upper" doing tasks that are already covered by native PHP funktions (e/g strtoupper()) - yet the Smarty stuff is less flexible in use (and probably slower since PHP functions are called via the "template engine detour"). All in all, any template designer will have to dig into the Smarty syntax and learn it before they can create working templates.

If I got it right, the compilation of templates means that files are translated from the "Smarty language" to PHP, meaning of course that these compiled scripts will be parsed again by the PHP parser on request.
Nothing against that - but when the syntax is so similar, why do we need the Smarty templates in the first place?
So from my point of view this template engine just looks a little like a big wrapper that does things you could do with plain PHP - and yet it is not much easier to use than PHP itself.

With those drawbacks - tpl designer having to learn a "language" similar to real scripting, a lot of overhead code on every request and nothing really you couldn't achieve with plain PHP code just as easily - what do I get out of using Smarty?

20 Mar 2002 18:26 mohrt

Re: Poor Performance

>
> % FYI, version 1.3.1 has some good
> speed
> % improvements by narrowing the amount
> of
> % code PHP must compile after the
> initial
> % template compilation.
>
>
> I can attest to these speed
> improvements. I converted a single very
> complex page running on PHPLIB template
> with multiple set_block() and parse()
> calls to Smarty. The page came up much
> faster with Smarty and my code is much
> cleaner than before! Plus, I am
> successfully using Smarty along with APC
> for even more speed. This is a truly
> excellent product. I can also use it in
> commercial products because of the
> license. Not surprising but I am
> converting everything to Smarty.


The 2.0 release has _major_ speed improvements, and Smarty now has a benchmark page to compare for yourself.

14 Aug 2001 09:26 bmatzelle

Re: Poor Performance

> FYI, version 1.3.1 has some good speed
> improvements by narrowing the amount of
> code PHP must compile after the initial
> template compilation.


I can attest to these speed improvements. I converted a single very complex page running on PHPLIB template with multiple set_block() and parse() calls to Smarty. The page came up much faster with Smarty and my code is much cleaner than before! Plus, I am successfully using Smarty along with APC for even more speed. This is a truly excellent product. I can also use it in commercial products because of the license. Not surprising but I am converting everything to Smarty.

07 Mar 2001 20:41 mohrt

Re: Poor Performance
FYI, version 1.3.1 has some good speed improvements by narrowing the amount of code PHP must compile after the initial template compilation.

02 Feb 2001 23:01 deekayen

Re: Alternative
Fair enough. I'll admit I haven't downloaded
Smarty, so I have said all of the previous without
even having looked at the code.

02 Feb 2001 15:11 andreyz

Re: Alternative
Plug APC all you want - it is cool, but apparently you have very little understanding of what Smarty is and what it does, because otherwise you would not have said what you have.

31 Jan 2001 17:01 deekayen

Re: Alternative
No, I'm not confused. I was just 1) plugging APC
because I think it's cool and 2) letting people
know about it because of people that can't use
Smarty because it might not be a practical
solution for them. I have nothing against Smarty.

Screenshot

Project Spotlight

ReciJournal

An open, cross-platform journaling program.

Screenshot

Project Spotlight

Veusz

A scientific plotting package.