
Once again I will raise the topic of the Template Engine in PHP. I'm afraid there will be a holivar ...
Recently, I notice a tendency that a beginner PHP developer (grievingly saying that not only a beginner) considers it his duty to insert Smarty or another Template Engine in each project, and then prove with foam at the mouth that it is necessary to separate the logic and the display. So - for starters, you should in your head share the logic from the presentation, and not scream - "I am smart, I share."
Another misconception is that the coder / designer doesn’t understand PHP tags, but he will understand Smarty - ask your coder’s friends, they don’t have any particular difficulty using PHP, and as an example I can give Wordpress - there are a lot of topics for him, and by no means PHP developers written.
I will give an example from the same manual on smarti:
- {php} - The tag {php} allows you to embed PHP code directly into a template. Of course, it is not recommended for use, but it can easily break the “separation”
- {include_php} - Used to connect a PHP script to a template, the function is outdated, it is advised for this to write its function for Smarty - such is a simple solution for the layout designer
Another disadvantage of Smarty is PHP4, which after
08.08.08 will not even crash ...
')
And the fact that the IDE is not friendly with Smarty and others like it - it just pisses me off (even if you set up the backlight, you cannot see the navigation through the classes and functions)
What is the alternative? Look at
Zend_View - a beautiful implementation of a native PHP template engine with syntax.
PS Looking back at your previous post about the
ranks of developers , you can use this for PHP:
- Junior PHP Developer - enthusiastically exploring Smarty and hedgehog with them
- PHP Developer - uses Smarty everywhere, but starts to suspect something
- Senior PHP Developer - writes its own template engine , understands what the salt is and maybe comes to the template engine ala Zend_View
- Lead Developer - does not think about such trifles
Update :
- template engine is just a tool for the separation of logic and display - if you don’t understand how to wield this tool with a tool, then nothing sensible
- use template engines with native PHP syntax (Zend_View is given as an example of one)