views:

170

answers:

2

I am getting familiar with Zend Framework (and MVC with PHP in general) for a personal project. I have previous experience with Smarty and have no major gripes with it, but I would like to use this project as a good in-depth learning exercise. Those of you familiar with different templating engines and ZF: Do you believe there are better templating engines than Smarty in conjunction with ZF and why? I would like to apply what I learn to the real world and production environments.

The personal project will be fairly robust. User management, sessions, security, database interaction, form input, jQuery, etc.

+1  A: 

PHP itself is a templating lanugage. Adding anything else on top of that will add more layers of complexity. Worst case try using XSLT.

Also look at these other questions on stackoverflow

http://stackoverflow.com/questions/1182167/the-best-php-templating-engine

CodeToGlory
Uh what? PHP is not a 'templating engine'
webdestroya
@webdestroya...look at http://stackoverflow.com/questions/1182167/the-best-php-templating-engine and many other forums if you wish.
CodeToGlory
I'm not simply asking for 'the best templating engine' in general. I am looking to learn from people's experience with Zend Framework and templating engines. Maybe there are pitfalls with using Smarty and ZF, etc. I know from experience Smarty does a lot that I don't want to reinvent. Also, heaven forbid I'm working on a project where the layout is built by a designer and not someone who knows PHP well. Templating makes it very easy to implement their layouts or site wide layout changes without touching the PHP code underneath.
manyxcxi
@manyxcxi I have used both Smarty and just PHP. It depends on how you want to organize as even Smarty generates and caches a pure PHP version anyways for performance reasons. If I were you I would go with Zend framework's default option which is PHP and avoid putting business logic in them.
CodeToGlory
+1  A: 

If you are using this project as a learning experience, I would suggest learning and using Zend_View, which is the templating (for want of a better word) part of ZF. This will be much simpler than trying to use any third party template engine, and Zend_View can do everything Smarty can.

In my personal opinion there are only two good reasons to use a separate templating language in ZF (or any PHP project):

  1. You need non-programmers to be able to edit and use the templates
  2. You need compatibility with existing templates written using that templating engine (e.g. Smarty templates from an existing project, or templates used by another non-PHP project)

If you do go down the Smarty route, the Zend_View part of the ZF manual has some Smarty examples: http://zendframework.com/manual/en/zend.view.scripts.html . There is also this tutorial on DevZone: http://devzone.zend.com/article/120 although it's a few years old now.

Tim Fountain