Search code examples
smartyphalconvolt

phalcon - Do we have Smarty Template Engine as C extension ?


I like to use phalcon for my next project, however i am in a Dilemma to use VOLT (built in Template engine) or SMARTY.

Reason why i am asking this question is Phalcon is written as C extension, so any library we add manually like smarty is going to kill the application performance which is the first reason why people use the Phalcon over other framwworks.

But if we have C-extenstion for the Smarty as well, it will be faster and efficient, so i just need to know do we have a option like that in phalcon ?


Solution

  • Phalcon is a great performance booster and unless you are doing a lot of heavy template rendering this will not be a bottleneck in 99.999% cases. Volt is not very different from other engines in the way that it creates a cached PHP render (if enabled) and reuses it later, i.e., most performance gain happens during the initial template generation, not actual rendering.

    Major (imho) of the Volt drawbacks is that it's not as mature and stable as other alternatives like Twig and Smarty. The guys at Phalcon are putting a lot of effort and doing a great job on Phalcon and the components, but they are not big enough (yet) to maintain it at the quality level most of us wish. As the result the chances of finding troubles vs. finding the relevant documentation are pretty high.

    If Smarty has a C extension and you are familiar with it, go with that. If not, but you want something with the performance twist you can use Twig, I've been using it for awhile with Phalcon and never had any issues. Otherwise, the difference in speed will probably be unnoticeable when using Smarty as a plain PHP library.

    In the Phalcon Incubator you can find implementations for integrating both Smarty and Twig.