Gilles Ganault wrote:
Hello
I'm no PHP expert, and I'm reading "Building scalable web sites". In
the tips section, the author mentions using templates to speed things
up. I was wondering how the template engines manage PHP pages that
contain calls to MySQL: In our application, the data returned is
different for most users, so the resulting page has different
contents. So why do templates (and opcode cache) improve performance?
Thank you.
Someone argued templates improve "development speed" by separating
logic from presentation. The templating systems all make that
arugment. Well, maybe. Separating logic from content is a worthy design
goal. But you don't necessarily need a templating engine to do that.
file_get_contents() works fine for me.
I spent a few weeks playing with SmartyTemplate once (one of the more
popular templating systems) and I didn't think it was worth the hassle.
the *.tpl files Smarty employs are a pain to work with (difficult to
debug) and it just doesn't buy you anything you couldn't do yourself
with good abstract code design and file_get_contents() for retrieving
html fragments.
Templating systems are great for Java Servlets: you can change html
with a text editor, without recompiling the code. But for interpreted
languages you don't need that anyway.
--
cut the board three times and it's still too short