PHP template engine
Feature-wise it seems good. My only concern is speed; I'm trying to squeeze as much performance as possible out of a 360. Anybody know the performance drawbacks? Or, have other suggestions?
Edit: I'm looking at the Zend Framework, and it seems it might be a better option even though I have less experience with it. Anyone used it?
15 Replies
Best would be to try it out and see how it behaves. Make sure you're using something like lighttpd and use FastCGI.
And obviously cache as much as you can
Speed-wise, you can't beat a plain PHP-based system. Just tell your designer to use or instead of <% … %> or whatever else some other template engines use.
Interesting comparison of PHP framework performance (17 months old)
I strongly recommend using just PHP for templating, and with that, naturally, logic and presentation separation. MVC is not required although it's a neat paradigm to work with.
And if you want a PHP framework, I recommend CodeIgniter.
@Azathoth:
And if you want a PHP framework, I recommend CodeIgniter.
+1
The no-framework PHP MVC framework by Rasmus Lerdorf
@krmdrms:
Templating Engines in PHP by Fabien Potencier
http://fabien.potencier.org/article/34/ … nes-in-php">http://fabien.potencier.org/article/34/templating-engines-in-php
This article is a bunch of personal opinions and preferences presented as absolute facts. Plus, it is biased to say Python is good, PHP sucks. May be, may be not, but that does not make PHP anything less than a template engine.
Shorthand not an option? Why not?
PHP is not a template engine because it is … ugly?
is not good but <% for b in a %> is?
PHP is a templating engine. Any other templating engine for PHP is just bad reinventing of the wheel. Besides, this topic has been hashed and rehashed countless times in the history of PHP.
> The PHP language is verbose. You need no less than 14 characters just to output a simple variable (and no, using the more compact
Why? If you're going to bitch about it taking 14 characters to output a variable, why ignore
EDIT: I briefly glanced over the rest of the article. He makes many generalizations about how horrible PHP is while at the same time using archaic or inefficient code to demonstrate how PHP is inefficient.
If you have short open tags enabled, and if one of your templates contain the above (which, by the way, is strongly recommended for XHTML pages), PHP thinks
This issue can be worked around, though, by writing:
'; ?>
It's a little tedious, of course, so I use a home-brewed send_xml() function which automatically adds the above (and an appropriate DTD as well) before printing the template.
But hey, it's your server, your PHP installation, and your app. Enable whatever setting that makes your life easy, as long as it doesn't compromise security
'?>
Besides, you don't need that to have valid XHTML (even for 1.0 Strict), plus there are issues with IE6 on pages with anything before doctype.
Also you don't really need to type the above line that much. For all the sites I did, I'd have to use once per site theme (for main template file), or per RSS master template.
@Mr Nod:
@Azathoth:And if you want a PHP framework, I recommend CodeIgniter.
+1 +2
@Azathoth:
And if you want a PHP framework, I recommend CodeIgniter.
I recommend Symfony
Any +1's?
@KipBond:
@Azathoth:And if you want a PHP framework, I recommend CodeIgniter.
I recommend
. SymfonyAny +1's?
:D
here's one: +1
get_contents();}
public function get_contents(){return "";}
}
class mypage extends tpl {
function get_contents(){
extract($this->variables);
$contents = << $var1 $form
HTML;
return $contents;
}
}
class myform extends tpl {
function get_contents(){
extract($this->variables);
$contents = <<...
HTML;
return $contents;
}
}
$html = new mypage();
$html->variables['var1']= 'test';
$form = new myform();
$html->variables['form'] = $form;
echo $html;
?>
The template classes usually also contain their own logic to set the $variables.
-alnr
Smarty is another layer and if you're not the only one doing is an this is going to be for users to develop templates/themes it's more support for you as they'll need to know a bit of PHP, HTML and Smarty….
If they just know HTML and learn a bit of PHP, they can get a lot done.
I know with the Gallery project