The Storyteller

Once upon a time there was Smarty!

January 5, 2008 · 77 Comments

With due respect to Monte Ohrt, Zmievski, Messju and those nice guys who contributed their time in Smarty.

I have used Smarty for a long time, even wrote a book on it and created a cheat sheet. But I think now its time to say there is no need to use an external template engine like smarty. With flexible view in MVC frameworks like CodeIgniter and CakePHP (Many others too) is there really any need to learn a separate template language like smarty? Once there was a time when people burnt their hand with RAW code and so called phrameworks and finally realized that they need something to separate the presentation layer from business. Some nice guys over there developed smarty and it saved life of a lot of developers (i mean developers). But that time is over. Seriously why the hell I need to learn a new templating language when a “echo” does the thing much better. Even smart frameworks come with some cool helper libraries where you will find helper functions to do some cool things that smarty’s date and time function does. I just dont need a wrapper over my PHP code which parse regular variable and echo them. Smarty just made itself extremely complex and useless too over the day, seriously.

I seriously don’t think there is need of Smarty anymore. Its dead! If you guys don’t agree with me, you can spend hell lot of time learning that {$name} actually does what you could do with “echo $name”. If you write a dispatcher which is smart enough to bring the variables from a controller scope to the scope of a view, why do u need to learn a separate parser like smarty? Moreover, of course it takes time in parsing the template files into equivalent PHP code and cost me some time. But hell no, I am not pointing to those microseconds I lost in extra parsing, I am pointing to the time I will spend learning smarty which is not needed at all. Learning all those functions, loops, logics, caching and others in smarty takes so much time that I would love to suggest you to learn writing efficient PHP code in template layer rather than learning something like smarty.

Update: Some of you commented that to keep designers away from PHP and to keep it safe, we should go for smarty. But is there really any designer who knows only smarty and no PHP? Is it really possible to write efficient code in smarty without knowing PHP? Nah, not at all. And there is {php} block which allow so called template designers to run unsafe PHP code inside it. Well, you can block executing {php} block from your side, but still smarty is not a solution to think that you are “secured”. And honestly, you should’t let your template designer write template code for you if they dont know PHP. And you should learn about XSS, SQL Injection and CSRF if you really want to live secured.

Sometime it’s better to realize thats its time to unlearn something.

Categories: PHP · Smarty

77 responses so far ↓

  • Omi Azad // January 5, 2008 at 1:32 am

    Some people would be very upset by this post I guess. I know lots of people who learned Smart and deploy sites with Smarty.

    But everyone must thank you for being so honest. :)

  • TLJ // January 5, 2008 at 1:52 am

    And some people always realized that PHP is in fact a template language on it’s own. Why use a template language inside another template language?

  • junal // January 5, 2008 at 2:14 am

    Ya, smarty is not smart enough anymore. now days, we love to eat cake, we love to ignite our code. but after couple years later we wont be satisfied just with a cake. we will love to have buffet lunch yay ! :D

  • s0enke // January 5, 2008 at 2:15 am

    Smarty has excactly one permission to live: If you don’t want template/html/css designers to access php code (and you wanna rely on smarty’s security layer).

  • OnyxRaven // January 5, 2008 at 2:23 am

    If you ever need to give a file to a ‘non-developer’ - I’d rather give them a language that cant be mis-used like pure php. Smarty lets you sort of ’sandbox’ those people, and then that compiles down to PHP anyway, so whats the diff. I prefer to use Smarty.

  • manchumahara // January 5, 2008 at 2:28 am

    then what’s your suggestion for the beginners ?

  • Marc Gear // January 5, 2008 at 3:09 am

    Excellent and very valid post. I’ve never liked smarty - it always seemed like there are better ways of separating display logic from page logic than implementing a new syntax.

    Smarty - and similar templating languages - are useful when you want to allow your users to edit the layout of the site or elements on the site and can’t trust the user input.

    I dont really thing that there is an argument for keeping designers away from writing PHP. If they are having to write smarty code, they might as well be using PHP which is much more powerful, and a far more valuable transferable skillset to learn. Otherwise, have them generate the HTML and get a developer to plug in the content. An unmanaged smarty implementation will allow arbitary PHP code to be executed anyway throught {php} code

  • kenrick // January 5, 2008 at 3:15 am

    how about they learn php? its really not that hard. besides if you are allowing designers to create php files, or get in your php code, you shouldn’t just let the software monitor what they are doing, and actual developer should have eyes on it at some point.

    i used smarty for a long time until i realized i wasnt really getting anything from it. i think its actually more confusing than bare php is, plus it has some overhead that you have to be aware of as well.

  • Evert // January 5, 2008 at 3:18 am

    My (single) reason to use a separate templating language is simple. We allow our users to change their application templates..

    Exposing them to PHP would be a huge security risk

  • atu // January 5, 2008 at 3:31 am

    I agree with this article. Those who think that php is to hard to learn for designers or php is a security risk are not up to date of what is possible. Learn the mvc principle and you wont build future applications around a template engine like smarty. Smarty is for people who sit on an idea like chickens on eggs.

  • Paul M. Jones // January 5, 2008 at 4:57 am

    I came to the same conclusion years ago (i.e., no need for a separate template language) and wrote Savant (http://phpsavant.com) as a result. It gives you most of the power of Smarty while using plain PHP as the template language.

    Zend_View, and of course Solar_View (http://solarphp.com), are its most recent relatives.

    Welcome to the non-Smarty world!

  • Lars Strojny // January 5, 2008 at 5:24 am

    Your post is really ignorant and you prove that at least on this topic you don’t have any idea about what you are talking.
    Take it this way: a frontend developer who does just HTML templates might not be aware of doing if (isset($var)) echo $var;. Instead they use smarty {$var}, which does the isset stuff for them. Or he might not be aware (and he should not be aware) of doing “if (isset($array)) and is_array($array)) { foreach ($array as $key => $value) { …} } else { …}”. Instead he will use {foreach from=$array item=item key=key}…{foreachelse}…{/foreach}. So Smarty is not outdate, it has in fact a lot of glitches I do not like but it is a good solution when you have a business process where the creation of the HTML templates are not done by the developers. And yes, there are guys out there who are much better in writing HTML (including nifty semantics, microformats, fixing browser glitches) than most of the average developer.

  • nick // January 5, 2008 at 7:04 am

    Take it this way: a frontend developer who does just HTML templates might not be aware of doing if (isset($var)) echo $var;. Instead they use smarty {$var}, which does the isset stuff for them.

    So the developer says toe-may-toe instead of toe-mah-toe?

    So, you’re saying that it’s not OK for these mythical frontend-only developers to recognize PHP syntax, but OK for them to recognize Smarty syntax. Honestly, is one really different from the other?

  • hasin // January 5, 2008 at 7:45 am

    @Lars

    If a designer can learn such a complex scripting features of smarty then why the hell they cant learn only for-each, if-else and echoing in PHP which really helps them to upgrade?

    And I dont think there is truely any single template designer who knows smarty but no PHP! Smarty is not HTML, Smarty makes it almost like another scripting language.

    I dont agree with you, Lars.

  • dedenf // January 5, 2008 at 10:34 am

    i’ve been using smarty for 3 years, and its doing great, the bad thing is (at least for me) i have to learn another languange that smarty provided.

  • Trophaeum // January 5, 2008 at 12:30 pm

    I’m too much of a fan of modifiers and post filters in smarty to say that it can be replaced that easily, its far too easy to forget to escape something if your not using a templating language setup, personally though im TRYING to migrate myself to phptal, its taking some work though as iv used smarty for years now myself as well… such an odd syntax when you compare the two :)

  • anupom // January 5, 2008 at 1:01 pm

    I liked this post! Excellent! I never found Smarty useful - there are much better ways to separate the display logic from application/business logic. IMO, using the good old MVC pattern is much smarter, simpler and easier than implementing a templating engine.

    He is dead, God bless his soul!

  • Kaloyan // January 5, 2008 at 1:26 pm

    Smarty is indeed very useful when the templates of an application are going to be edited by non-developers, or 3rdparty developers. I know that it is almost like a new scripting language, but yet it is quite more simplisitic then pure PHP. I do not agree that HTML designers can learn PHP’s basic stuff like “echo” or “foreach”, and to prove my point I’ll say to have a look at WordPress themes. They have PHP as their template engine, and the designers are very good at copying the already existing PHP stuff in the templates, but it is very hard for them to add new stuff on their own.

    Another advantage of Smarty is that it acts as a security layer. Its “almost like a new scripting language” syntax acts as a sandbox from performing malicious deeds when in “PHP land”. Here is an example - I can put php code in a WordPress theme that deletes all the records in the DB of that WP installation. Any 3rd party developer or designer creating a new theme/sking for your application can do that, right ? So how can you prevent something like that ? It is very easy w/ Smarty - you just can not do that :) You see, this is the problem with pure PHP — it is both simple enough for basic stuff like echo’s and foreach loops, but in the same time it is powerfull enough to screw up a lot of stuff. That’s why Smarty is an excelent solution for any application that offers “outside” developers to do new themes/skins. In the same time, if you are doing an application that does not have such a feature and you as a developer do all your HTML templating, then you cna use whatever you want - whatever makes it more easier for you: plain php, smarty, savant, whatever :)

  • Viktoras Agejevas // January 5, 2008 at 3:00 pm

    Nice post, my templating system FryPHP is made to deal with the problems you have noted. It uses plain PHP, but has to offer more template specific features.

  • hasin // January 5, 2008 at 4:28 pm

    @Kaloyan

    If you can write PHP code that deletes tables from a DB in a wordpress template, that is also true for smarty templates. Your template designer could be enough smart ass to write a hook (or filter) and cause a disaster.

    Smarty doesnt reduce the risk in such cases.

  • Martin F // January 5, 2008 at 9:50 pm

    Lars Strojny your post is really ignorant and you prove that you know nothing on the subject. Seriously, don’t check if a variable is set in your view, if a variable is passed to your view then you’d better make sure it’s set in your controlling logic.

    And your claim that front-end developers shouldn’t be aware of basic PHP code is down right insane. You work in an industry where technologies mix together more and more, it’s impossible to do any serious website these days without knowing both HTML, Javascript, XML etc. And if you know javascript then you can damn well learn basic PHP too.

    This isn’t 1992, there are certain standards developers have to be held to, and such a thing as front-end developers doesn’t exist in any serious business; the fact that you even seem to think so scares me, hopefully there aren’t too many with the same thoughts.

  • Jay M. Keith // January 6, 2008 at 12:45 am

    Hasin,
    You’ve managed to hit the nail on the head with this one. I’ve been a long time user and supporter of Smarty, especially when utilized in non-framework environments. At my workplace often we have folks that do not know PHP making modifications to code. Thus far, I’ve been able to train them to leave stuff within {} alone. However, as I begin to utilize the various frameworks, I’m finding the good old PHP method as well as the various Helpers that are available in the Frameworks as being beneficial.

    Lately I’ve been using the Zend Framework, and have realized that incorporating Smarty is basically pulling double duty. Sure I have devised methods to utilize the View Helpers through Smarty, but it seems to cause redundancy that is not necessary in the Framework environment.
    Now, if I have a simple (non-framework-based) site that I’m putting together, I consider Smarty. But, as I get further into using the frameworks, I’m finding it more laborious to use.
    It’s great to see that I’m not the only one feeling this way.

  • Ehsan // January 6, 2008 at 2:08 am

    After using Smarty for about 1.5 years I realized that it is something like taking the longer route to your destination than the straight forward route. I completely agree with Hasin’s reply to Lars comment.

  • Pavel Shevaev // January 6, 2008 at 2:03 pm

    Quite for the very this reason - convenient usage of raw PHP in templates - I hacked up the initial version of {{macro}}, a flexible and pluggable templating system which is just a macro based sugar coating over raw PHP.

    If anyone is interested, I blogged about {{macro}} a bit here - http://efiquest.org/2007-11-04/14

  • Björn // January 6, 2008 at 9:44 pm

    I agree that Smarty is not state-of-the-art anymore, and with those new MVC enviroments we all can develop complex applications much quicker than we used to some years ago.

    The cool thing about Smary is, I never had the feeling to actually have to learn it. After installing, just divide application and visualization, then go for it. No need to learn a new trade, just go for it. And that hasn’t changed since now.

    Therefore my opinion: Smarty is still a good and clever way to do that kind of programming, if you don’t use a MVC framework.

  • Gerard Sychay // January 10, 2008 at 10:13 pm

    I think Smarty is still very valuable. Mainly for the designer argument.

    Many people on here are saying there is not much difference between having to learn Smarty syntax vs. PHP syntax.

    From much experience, let me tell you, for a non-technical person, there is a BIG difference between {$var} and .

    The less syntax the better.

    A lot of it is based on how your team is structured. Do you have a separate graphic designer, front-end developer, back-end developer? Then you may not need Smarty. If you only have a graphic designer and developer, then Smarty comes in handy.

  • Clay Loveless // January 10, 2008 at 10:18 pm

    Bravo, Hasin!

    If you’re going to make designers learn a language (as you are when you’re endorsing Smarty), why not make them learn XSL or JavaScript?

    At least those are “real” languages, and have some usefulness outside of the small box that Smarty-thinking puts one in.

  • developercast.com » Community News: Has Smarty’s Time Come? // January 12, 2008 at 1:09 am

    [...] points out Hasin Hayder’s post on the subject. Hasin (ironically author of a Smarty book) has recently come to the conclusion that [...]

  • hasin // January 12, 2008 at 12:42 pm

    @Paul - Thanks a lot and yeah, non smarty world makes me smart.

    I have read your blog post regarding it. Its cool.

  • stik mig så den staveplade » Blog Archive » tid til nørderi - episode 2 // January 13, 2008 at 8:47 pm

    [...] at bruge eller om det bare bliver “endnu et lag” i stakken der skal håndteres. jeg kan også se at jeg ikke er den eneste, og efter at ha mogget rundt i symfony er jeg ved at være [...]

  • wenbert // January 14, 2008 at 8:50 am

    MVC Framworks is teh c00l!
    Zend Framework

  • PHP Usergroup Munich » Blog Archive » He Mr. Smarty Pants // January 14, 2008 at 6:21 pm

    [...] Hasin Hayder asks an interesting question: Is Smarty’s time over? [...]

  • Tim Swann // January 14, 2008 at 8:18 pm

    No-one is mentioning caching, the best feature about Smarty is the caching. It’s all very well to say you should write better more efficient code but if you have a very high traffic site and need to perform complex queries, you can run the page once and then spit out the cached version based on any parameters you want. That makes page rendering very fast. Smarty gives you the control to do this on an entire page or just bits of it.

    If on the other hand you are generating simple templated pages with no traffic pressure, then yes Smarty is probably overkill.

    I dont think it’s a matter of Smarty being the right or wrong thing to use, it’s a matter of picking the right tools for the job in hand, and yes sometimes that is Smarty.

  • A morte das engines de template at Renan de Lima // January 16, 2008 at 6:01 pm

    [...] uma lista de discussão Hasin Hayder divulgou um de seu blog um post (Foi se o tempo do Smarty) onde explica o motivo da não necessidade de se utilizar Smarty ou qualquer outra engine de [...]

  • A morte do Smarty at Renan de Lima // January 16, 2008 at 6:20 pm

    [...] uma lista de discussão Hasin Hayder divulgou um de seu blog um post (Foi se o tempo do Smarty) onde explica o motivo da não necessidade de se utilizar Smarty ou qualquer outra engine de [...]

  • ivan // January 17, 2008 at 2:10 am

    well, ok,really, how much time do you really need to learn that {$foo} does same as echo $foo ? :)

    It took me about two hours to figure out the basics of Smarty, and after first 2-3 days I already knew everything I needed (and it was like 95% of everything I ever needed from Smarty syntax), so I think that “the need to learn another syntax” is really not such a big deal a you present it.
    And you get syntax that uses less ()[]“” characters and, in case of a bit more complicated expressions mixed with HTML it is much shorter and clearer than echos, IMO. Plus smart editors support the syntax highlighting and even code checking for Smarty, which is not the case with html inside echo statements..
    Also pre/post compiling filters are very cool thing, you can’t do that easy with plain php..

  • Flash // January 18, 2008 at 10:58 pm

    Lately I have been contemplating the next logical progression for moving away from using Smarty.

    I have previously used templating systems before Smarty (patTemplate) and have discovered that actually using a templating system slows down the development time and accumulates more code.

    The only reason I ever used Smarty was to separate my php code from my design, not because I needed other designers to work on the templates but to keep my code tidy and maintable.

    Though I still believe the following is true:
    MVC > Smarty > Plain PHP files

    The MVC concept is a huge improvement over the templating solution as many have pointed out, less overheads, more flexability (the pure power of PHP itself) and no need to learn any extra syntax.

    But using a templating system is still better than using PHP mixed with html with no functions or objects (mainly because its an absolute mess!)

    Also the purpose I loved about using a templating system is suitable for small projects, the big boys like Cake and Igniter are a bit overkill (others may argue in defense of this) but a simpler MVC would be more ideal for the smaller frys.

  • Rudolf // January 20, 2008 at 5:51 pm

    Hasin, if you hate Smarty that much, why do you still receive money from book sales?

    Why don’ you share with us how much money did you earn?

  • hasin // January 20, 2008 at 7:34 pm

    I dont hate smarty!

    I just said its useless now!

  • Being Smart i.e. - PHPUGFFM - PHP User Group Frankfurt am Main // January 24, 2008 at 11:30 pm

    [...] http://hasin.wordpress.com/2008/01/05/once-upon-a-time-there-was-smarty http://fosterburgess.com/kimsal/?p=406 http://paul-m-jones.com/?p=273 [...]

  • TRIVUz // February 4, 2008 at 4:51 am

    Agree with Omi bhai… everyone must thank you for being so honest. :)

    great article… :-)

    (aytao gelo.. :P)

  • Once upon a time there was Smarty! « mihailt // February 10, 2008 at 11:33 pm

    [...] 10, 2008 php Tags: php, smarty, template engine достаточно интересные размышления о [...]

  • Anders Fredriksson // February 11, 2008 at 12:12 am

    The only reason for using Smarty is to stop programmers being tempted at doing advanced php-stuff which should really be done in the controller. and the {php} option can as you probably know be turned off to keep it safe from clutsy developers.

    However, I agree with you that there is no point in having a different syntax than php in the view. But until we can limit what types of php-calls that can be tone in the view, I think we have to stick with a templating language like smarty.

  • AmirBehzad Eslamiَ // February 13, 2008 at 12:51 pm

    Please note that a Template Engines and MVC Architecture answer two different questions. Sometimes you need to use Smarty with an MVC-Framework.

    For example, in a Blog Provider system, your users may want to change their blog templates. You can’t use pure PHP in these blog-templates.
    That’s not safe. Template Engines are designed to solve this problem.

    If you’re going to allow everyone to access to your “view” files, then you need a Template Engine.

  • Josho // February 18, 2008 at 5:56 pm

    Are you sure you are not simply suffering from expertise syndrome?

  • hasin // February 18, 2008 at 10:12 pm

    Josho - The term seems interesting “ES - Expertise Syndrome”. I was familiar with “MAD - Multiple Ambition Disorder”

    So what is ES? Can you help me the understand that?

  • Edouard // February 22, 2008 at 3:11 am

    http://www.travisswicegood.com/index.php/2008/02/13/expertise-syndrome-defined
    Expertise syndrome explained.

  • The death of templating engines // February 22, 2008 at 6:44 pm

    [...] at it this way. Hasin Hayder literally wrote the book on Smarty. He himself accepts that we no longer need it. What more can I say? Bookmark It Hide [...]

  • PHP::impact ([str blog [, str comments]]) » Blog Archive » Smarty is dead // February 29, 2008 at 11:26 pm

    [...] Hasin’s post: Once upon a time there was smarty Posted by phpimpact Filed in PHP, [...]

  • Smarty is dead « PHP::impact ( [str blog [, str comments]] ) // February 29, 2008 at 11:29 pm

    [...] Hasin’s post: Once upon a time there was smarty Posted by phpimpact Filed in PHP, [...]

  • Koder // March 2, 2008 at 4:41 am

    True, Smarty is completely useless. People with little or nothing programming knowledge will argue or deny this, like they are doing here or in other blogs or forums.

    To all the designers or junior developers that support Smarty, my advice is to follow the steps of more experienced programmers, like Paul M. Jones (he posted a message above). If the guy that wrote the template engine that Zend is using tells you not to use it, don’t use it. And if the guy that wrote a book about Smarty tells you that it’s useless, guess what, right, it is useless.

    We, programmers, cannot keep arguing with web designers or web developers about this stuff.

    Happy coding!

    -koder

  • batman // March 5, 2008 at 2:32 pm

    It is just so funny to hear developers talking about Smarty and template engine without any caching considerations.
    It is one of the purpose of such a langage, and we also avoid to use long <?php … tags that annoys the reading of HTML.
    Besides MVC doesn’t bury templating engine at all, or you didn’t get a bit of what is a MVC (you need to write views, and they can be in Smarty for instance).

  • Aishiteruno // March 11, 2008 at 11:21 am

    Once upon a time, there is one man who hate smarty because he think Smarty is too big for just a template engine. He think what’s the point to learn Smarty language if he knows how to coding with PHP. He always work alone, so he always think template engine is just for ‘team works’. Then one day, something happen and forced this man to learn Smarty template. Suddenly this man realized that by separating business logic with Smarty, he can create more and more website faster than he ever create. He just need to create one business logic for login page, registration page, news page, gallery page, etc and with that business logic page, he can create another website project just by redesign its presentation layer. Maybe he still hate smarty because Smarty is too big, but deep in his heart, he admit that using Smarty as his template engine is always worth something. Now he live happily-ever-after in the land of PHP-far-faraway. Moral of the story: For someone who never know Smarty, it’s their choice to learn it or not. For someone who already know Smarty, it’s their choice to using it or not. We never know what’s the meaning of ’sweet’ or ‘bitter’ if we never tasted it. We never know if ‘black’ is our colour if we never wear it. Who knows if Smarty is worth for someone?

  • David // March 12, 2008 at 5:55 pm

    I’ve been using smarty for several projects over the last 3 or 4 years. First it was the separation of PHP and HTML code that seemed most important for me. Now it’s also reusability of easy to grasp code snippets.
    During the last 2 years I’ve basically developed my own MVC framework, strictly object oriented and quite powerful. It’s probably not as big as Cake or Zend or whatever, but it suits my application and it is efficient (both in development time and application performance).

    When designing complex page layouts I don’t know what I’d do without HTML syntax highlighting (including smarty syntax, thanks to phpEclipse). It’s just more convenient and less error-prone.

    And there is one more thing for MVC concepts to consider: once you use smarty you are forced not to use PHP code inside your page (well, as long as you don’t use {php}{/php}). Thus you can always be sure that your MVC concept still holds. I’ve split my templates in quite a lot of snippets for re-use (e.g. all the form stuff) and I can always be sure that there will be no inline php code doing anything weird. Can you be this sure when calling functions or including other php files instead of {include}-ing a template file?

    I understand what the original author is saying and why. But I think that smarty _can_ be part of MVC, and if you do it right, you get clean code that is easy to maintain and less to type than traditional php/html code.

  • Norbert // March 17, 2008 at 2:04 pm

    PHP frameworks is kinda new for me, but doing more learning and reasearch it seems that it’s even more complicated, very limited, same old php coding with some presets, so IMHO smarty is the best choice for CSS/xHTML coders, it’s straight forward and keeps designers out of the code, that’s what developers want init ;)

  • Bimal // March 18, 2008 at 5:09 pm

    I love smarty, and have spent a lot of months in it. I respect the way; it is not a template engine. Better call it to have a different programming and presentation.

  • Eye on Web » Smarty мертв? // March 28, 2008 at 3:48 pm

    [...] (кстати, автор книги о Smarty :)) заявляет, что это так. В своем блоге он признает, что был не прав. Приводит аргументы [...]

  • olivier // March 29, 2008 at 9:40 pm

    What about DOM templating with a jQuery-like syntax ?

  • Iñaki // April 4, 2008 at 11:55 pm

    I’ve been using Smarty in the last 2 years.

    You says “Why learn a new script language for make views?” or “But is there really any designer who knows only smarty and no PHP?”

    If you says that I’m concluding that the designers have to learn PHP (or ask for help to developers). OK.

    Now, it’s simplier for a designer learn:
    echo trim(str_replace(’#', ‘@’, htmlentities($text)));
    instead of:
    {$text|escape:”html”|replace:’#':’@'|trim}

    ?

    I think if any designer needs to learn some scripting language for make templates, it’s easer Smarty than PHP. Why? because Smarty it’s an extension of PHP. A friendly user extension of PHP, why it’s the simpliest for a designer learn all of string functions in PHP if in Smarty are very simplier modifiers?

    It’s easer for a developer too. In my case it is! Why I’ll develope an app using only PHP for templates if I have an API like Smarty that help me with my templates?
    Develope my owns PHP functions, my Helpers to help me in my templates it’s another discussion. We’re talking what is easier y simplier for use or learn.

    Now, if you guys want to talk for quality attributes for our apps using Smarty like performance, it’s another discuss too, and I’m completly sure that it’s better use only PHP functions that Smarty, of course.

    Sorry for my english.
    BR

  • Ortzinator // April 7, 2008 at 10:24 pm

    As I understand it, a lot of CodeIgniter developers use Smarty for templating.

  • PHP - Abandono consiente do Smarty? « Julio Vedovatto // April 24, 2008 at 8:20 pm

    [...] view, web services, xml, xsl, xslt, zend Em um post em seu blog, Hasin Hayder finalmente concordou que não tem mais utilidade a linguagem de programação do Smarty (isso que ele escreveu um livro sobre Smarty :P). Só demorou para ele ter essa conclusão, muitas [...]

  • PHP - Abandono consciente do Smarty? « Julio Vedovatto // April 24, 2008 at 8:21 pm

    [...] view, web services, xml, xsl, xslt, zend Em um post em seu blog, Hasin Hayder finalmente concordou que não tem mais utilidade a linguagem de programação do Smarty (isso que ele escreveu um livro sobre Smarty :P). Só demorou para ele ter essa conclusão, muitas [...]

  • signora // April 30, 2008 at 7:24 pm

    I believe as a designer that the engine is good for seperation from a developers point of view only i.e. when selling closed source scripted php you can still allow for customers to edit the theme and layout but not the function. (albiet they need to learn how to use smarty syntax first)..this can be quite daunting to someone who doesn’t know or recognise programming syntax and how it works. For me personally I do not wish to learn smarty above php. Learning simple php is as easy as learning html/css, learning OOP is a much more time consuming difficult task that requires focus and dedication. If I where to step into programming PHP would be my choice like millions of others for obvious reasons. I also believe php is the (cryptographic) key to smarty once you have learn’t php smarty is simple, not true vice-versa.

  • "David Bennett" // May 3, 2008 at 12:45 am

    Aren’t smarty templates ’safer’ than direct PHP? Building a user configurable system that allows site maintainers to upload templates without worrying about rouge code with system calls and embedded database commands.

    It would seem that this Smarty or an advanced template system would be a valuable addition to applications with user configurable views.

    Am I missing something?

  • Andreas Dareios // May 11, 2008 at 12:52 am

    Fyuh…
    I’ve heard smarty once. But never learn it. Now I’m learning MVC Framework, but really confused on choosing the right one. The candidates are Zend, Cake, & Tigermouse. The latest is based on smarty template engine. While Zend & Cake have their own template syntax and not recommended to incorporate them with smarty. But this article and the comments posted by all of you folks really give me some pictures about the developer realm world wide. Thanks you folks. So, now I will focus on learning Cake, and waiting for the other great framework. Tigermouse is lack of documentation. I’m not succeeded installing Zend. IMO, framework make coding more “fun”. Thanks to Hasin and all folks.

    br,
    andreas.

  • Smarty is dead | Eye on Web // May 23, 2008 at 4:17 am

    [...] Хайдер (автор книги о Smarty :)) заявляет, что это так. В своем блоге он признает, что был не прав. Приводит аргументы [...]

  • Zgodila se je prva slovenska PHP konferenca | Internet Solutions // July 9, 2008 at 4:59 pm

    [...] Na spletu se odvijajo prave vojne okrog tega. Eno je povzročil sam pisec knjige o Smarty-ju Hasin Hayder. Jaz pa pravim kakor vam drago Prenesite si prosojnice od [...]

  • Delifisek // July 19, 2008 at 11:29 am

    True and what about short syntax

  • Why Do People Hate Smarty? - The Geek Blogs - We tell it like it is, or was, or I mean is, yea. // July 25, 2008 at 9:46 am

    [...] wrote a blog post stating a few comments about the use of MVC frameworks and the likes. The post can be found here. Anyways, he goes on saying how Smarty is pretty much a lost cause because of the “ease of [...]

  • Dan // August 4, 2008 at 11:40 am

    Who really cares? I like Smarty, you don’t. Some people like Windows, others Mac. Its all preference and whats needed by the current task at hand. It took me a total of 30 minutes to skim through Smarty’s tag documentation and grasp it. Its pretty much an advanced form of using BBCode in forum posts. BBcode can be done in HTML, but forum moderators do not want users being able to do that, so BBCode exists as a sandbox.

    And yes, there ARE successful companies with job openings for both “HTML only” people and “PHP only” programmers. In a truly successful development environment, everybody is specialized at their job, and one person stepping on the toes of another is minimized.

  • al // August 5, 2008 at 10:01 am

    Well, given between

    <?php echo(’{$headline}’);?php>
    and
    {$headline}

    which one do you prefer?

  • Bimal Poudel // August 15, 2008 at 4:31 pm

    Smarty had a big disputes in here. Just look at my website, how many projects I might have completed with Smarty. In a small business, it does not satisfy you, while in large business, your designers are likely to play your codes, and NOT USING Smarty could be a loss to you.

    Use only if it supports your needs. My suggestion is to use it if you have started developing a project even without a final design, it helps. And in other cases, you can created advanced-theme-able projects with this third party tool.

    Try to find out a better hosting server to give you a little more memory for empowering the performance of Smarty.

    Good luck with it.

  • Binary Systems Design » Blog Archive » Why every new developer should learn Smarty // September 2, 2008 at 1:09 am

    [...] deciding use it as the framework for my next project. Halfway through the project I ran across this article. My heart sank as I read on and the author Hasin Hayder, (Smarty contributer and author of four php [...]

  • Mike // September 10, 2008 at 8:38 am

    I am a php developer and have been given the job to work on a site that uses smarty. This is the first time that I’ve had to use smarty and I can guarantee that it is USELESS. I cannot write useless in big enough text.
    I believe in separating logic from presentation.
    I believe php is a templating language.
    I believe in making things simple for the designers that create the templates for my web sites. The designers have learned sufficient PHP to do what they need. Smarty is another language to learn and it is painful. PHP does it so much more efficiently. If a designer can learn Smarty then they can learn the PHP that does exactly the same thing. I have seen designers learn PHP (the little bit they need for templating) and they feel empowered. Any responsible designer will stick with the code that is required. If it’s necessary to block a designer from using PHP then you’re not trusting them so do not use that designer. PHP for templating is easier to learn than Smarty.
    Smarty is a waste of time. Sure there are people that know it and use it. I have no beef with someone using something that they’re comfortable with. I do suggest, however, that anyone new to the website business is far better off learning the tiny bit of PHP that will get them creating templates. What I would prefer to see instead of Smarty is a site dedicated to the templating features of PHP. It could show the php for each of the Smarty elements and for the Smarty helpers it could show the helper functions from the various frameworks out there.
    Maybe there was a need for Smarty in the past. I did look at it (very briefly) several years ago and wondered why anyone would use it because PHP is so good at templating all by itself. I stuck with PHP and the designers I work with have done the same.
    I just did some looking around for problems with smarty and there are quite a few sites dedicated to the subject. I think that’s enough evidence to prove that it’s a waste of time.
    So to sum up, if you’re new to web design and you’re interested in PHP then learn the simple PHP that will get you templating. Do not learn Smarty. Smarty is like learning anything proprietary. You are stuck with a limited piece of knowledge that can’t be used anywhere else. Learning PHP will broaden your horizons rather than narrow them.

  • Tom // September 18, 2008 at 3:21 am

    Smarty is complex and hard to learn from zero but it is easier to learn than PHP. Just like PHP, hard to learn from zero, but easier to learn like JAVA.
    Bit it seems if you don’t know Smarty you agree with Hasin, but most of the guys who know very well, they like Smarty very much. I recommend you guys to learn it and use it in a large project and your programming style will be changed forever.
    BTW I don’t think it is the same thing:
    echo $PHP_SELF and {$PHP_SELF}. And yes, the graphic guys can learn Smarty as they learn Flash Action script but they are graphics so to make a nice and secure code is not so joyful like for the developers so they can copy/paste ugly tabulated cycles as they want. I’ve found this article because I was looking for another templating system but I think this article is a pretty good advertisesment for the templating system, maybe not for the Smarty.

  • ozzy // October 6, 2008 at 4:37 am

    Am I missing something?
    This very day I put out a post on Drupal’s theme forum here http://drupal.org/node/317370
    advocating for Smarty to be made the de facto templating engine for Drupal.The PHP code in the phptemplate engine was driving me crazy.

    And here I come to this dude’s site only to read this (not so clear) argument against Smarty.
    FWIW Smarty works.Period.After working with ASP.Net for 5 years and Smarty for 4 years (not to talk of JSP stints), I can affirmatively say Smarty works and rocks.Combined with the ZF, you have a robust combination for implementing MVC web sites.
    Hasin pls clarify whats the advantage of manually generating HTML from PHP code as
    opposed to Smarty’s dynamic placeholders(and filters+plugins)?

    BR,
    Ozzy

  • Mick // October 8, 2008 at 6:19 am

    I have to agree with this article. Now that PHP is being used to build enterprise solutions we to look at new ways to solve the designer/developer issue.

    We experimented with a unique idea using php5’s new DOM module. And all the designer needs to be aware of, is three new attributes ‘VAR’, ‘CHOICE’, ‘REPEAT’ they cannot change anything else leaving the logic to the developer and design to the designer. So fare I have had over 15 designers use it and all have walked away happy with the development environment they used. It allows for designers to use dreamweaver/photoshop apps for designing without having to see one piece of php code.

    After having great success with this system locally we have now setup an opensource project so get the response of the public: http://www.domtemplate.com/

    Maybe this could be the next generation of template engines.

Leave a Comment