I have some experience in PHP4, but after learning the object-oriented parts of PHP, I'm having difficulty understanding how to use the Smarty template engine.

The official documentation appears to require a level of knowledge I don't have yet so it doesn't seem like a good place to start.

What do I need to know to jump into Smarty template development? Or if Smarty isn't the standard PHP template system anymore, how should I go about templating?

  • 2
    Why PHP4, PHP 5 came out like 6 years ago? – Zachary K Apr 4 '11 at 15:04

Personally, I find the smarty documentation fairly satisfying.

However, if you are not particularly proficient with PHP, that's not a smarty documentation problem, rather a lack of php knowledge problem :)

Plus, I understand that Smarty documentation is heavily based on Unix because, well, that's what PHP was originally meant to run on! Thus, if you use Windows and have never seen Unix/Linux, that might be a problem as well. My suggestion is that, if you're using Windows, you create a Linux virtual machine, something to go by like Ubuntu, RedHat, etc. That will give you all the tools to run php/smarty in the environment it was supposed to work in.

While I agree it will take you a bit more time, I am confident you will not regret this choice on the long run.

I also think Smarty holds up well for large projects. When I was using Smarty to do newer work in the intranet of an Italian bank with over 200 branches, I didn't feel Smarty was limited in any way.

  • If you can't comment on other answers, you can include the relevant information in your answer instead. :) I've done that for you in this case. – Adam Lear Jun 3 '11 at 17:23

Smarty has good documentation, but when you use OOP it’s better to use something which looks better for OOP, and use something like MVC when you want to learn it.

There are some framewoks which use MVC. For small things I use Smarty too, but when you have large projects you need something more than Smarty, I think.

  • Symfony 2 has a good template engine: it’s Twig. You can also use Twig as a standalone engine.
  • CakePHP.

And you can read the documentation on php.net for OOP to learn it.

  • suggest some good books than that smarty docs. – user22115 Apr 4 '11 at 12:39
  • The only book i know is "Smarty PHP Template Programming and Applications" but Smarty is not so complicated that you need more then the online documentation ;) @user22115 – René Höhle Apr 4 '11 at 13:00
  • Yea I have never needed more than the online docs. – Zachary K Apr 4 '11 at 15:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.