Template or not to template that is the question

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Template or not to template that is the question

Post by AGISB »

For my current project I have now to decide wether I go with the current design or use a template engine. I search the web and it seems that there are many pro's and con's about it.

From what I gathered pro's can be:

- code are different different from design elements
- easier for biger projects
- caching of static pages

con's could be:

- longer execution time
- complex template structuring
- security issues due to possible search engine attacks


Now my current design basically includes the design elements but I use the code on the same script than the content. No problem as I am developping on my own. For most codeing I use OOP so there is not much code on the content pages.

So how much sense makes it for me to use something like smarty basically just for caching? How much overhead would the template engine build?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

for the flexibility they offer, they add very little overhead. Depending on implementation, it can be very low to marginal increase in rendering time..

"search engine attack" is a new one that I have not seen or heard of.
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

A search engine attack is when a search engine like google is used to find certain pages that are unique to a program that has a weakness. So the attacker finds all pages that use this program and use the exploit against any or all of them.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

oh.. that.. template engines aren't alone in this "problem"

all users of any software that do not update often enough, or quickly enough have this issue.. If you write your own, you may have an issue similar to massively distributed ones, but the damage potential is, likely, far less.. (for other sites anyways)

That mostly has to do with your security programming..
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

purely from a server point-of-view: use some template engine to generate as much static content as possible. Static pages are much more easily cached than dynamic pages.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Re: Template or not to template that is the question

Post by Buddha443556 »

AGISB wrote:So how much sense makes it for me to use something like smarty basically just for caching?
Does not sound like you need a template engine but just caching? Do you need caching?

There's nothing wrong with using includes.
Post Reply