Smarty is a templating engine, as everyone knows. It has a big market and is being used by companies like WHMCS for building great tools. It’s a great tool to be used in the development of projects of small and big levels.
Today, we are going to discuss about its benefits and losses. Who should prefer using smarty in his/her project and who should stay away and continue with PHP itself.
Some might argue that Smarty does what PHP can do already: separate the presentation from business logic. The PHP programming language is great for code development but when mixed with HTML, the syntax of PHP statements can be a mess to manage. Smarty makes up for this by insulating PHP from the presentation with a much simpler tag-based syntax. The tags reveal application content, enforcing a clean separation from PHP (application) code. No PHP knowledge is required to manage Smarty templates.
The importance of this separation is situational. It is commonly more important to web designers than it is to PHP developers. Therefore, Smarty is commonly a good fit when the roles of developers and designers are separated. There is no right or wrong answer: every development team has their own preferences for managing code and templates. Aside from a clean tag-based syntax, Smarty also offers a wide variety of tools to manage presentation: granular data caching, template inheritance and functional sandboxing to name a few. Business requirements and the PHP code Smarty is being used with will play a large role in determining if Smarty is a good fit.
In cases where efficient template management is crucial or the case where web designers (not PHP developers) are managing templates, the strengths of the tag-based template syntax are quickly realized. If the project size scales to hundreds or thousands of templates, template inheritance keeps template maintenance streamlined. What little Smarty adds technically (a tag-based syntax + 1-time compile step) is easily overcome by the time saved with template maintenance.
People who are looking for development of projects that can use multiple themes should opt for smarty and can do lot of good work with it. As I mentioned before, it is a template engine that can help you in keeping your PHP and Theme Files separate.
Who should not go for smarty?
People who do not want to implement separation in presentation and functional layers of the project should not look for Smarty.
People who are always looking for great community for support on programming languages and need lot of documentation on it, should not opt for it. Smarty has its own community and large documentation too but it can be a bit confusing if you require an instant action / solution, as you will not get a smarty developer easily.
Smarty is clearly not meant for every project. It is just one solution for managing the presentation of your PHP applications. Your business requirements along with your development team preferences will largely decide of Smarty is a good fit. Be sure to read All about Smarty, Use Cases and Work Flow, Template Inheritance and Syntax Comparison. And of course, install Smarty and give it a try.