I’ve been working for a while with Kohana 3 and really enjoin the features provided by it such as HMVC, ORM and caching, features that makes our live as developers really easy allowing us to create really nice pink application. But, yeah … there are no pink ponies jumping on rainbows, or are there any ?? I am talking about views from Kohana, I really don’t like the way they mix HTML markup and PHP code it is really annoying when you see a foreach loop and inside it some echo, I am sure that you really understand what I mean. But tanks God there are some really smart people that were thinking about this long time before, so this people have invented something that we are calling Smarty. Smarty is a template engine, a template engine’s life purpose is to provide a clear separation between the application business logic and the way the data presentation, or you know…in ancestor time this was called design right ?. Well that is necessary because there are two main categories of players: developers and designers and each loves only their own toys. This article is not aiming to learn you advanced topics about Smarty, I suppose that if you are instead of it you can ask the almighty Google about that.
I have wrote some glue code that make possible the utilization of the Smarty template engine in Kohana very simple and transparent, so you don’t have to change nothing in your existing application. All you have to do is to download the module form Smarty-views-for-Kohana repository, extract it in your modules folder and add the following line in your bootstrap.php on module loading section and you are ready to go.
'smarty' => MODPATH.'smarty', // Smarty views
So basically now you have finished, have fun with Kohana and Smarty. 😉