Thread: [Phplib-users] [Fwd: [phplib] general template question]
Brought to you by:
nhruby,
richardarcher
From: Philip S. <ph...@st...> - 2001-08-14 06:53:10
|
Sending this to the new list. Philip Strnad wrote: > All, > > I've been using PHPLIB since the 6.x days and have never used the > Template class (please don't flame me!). I always had too many other > things going on to take a look at it. I know how great this class is > supposed to be, but I have one question: does anyone use Template for > dynamic pages or do most of you use it to "write" HTML files that are > then served statically? Is there a performance impact in opening a > template file everytime a page that uses the Template class is > requested? My whole site could work really well with templates. > Unfortunately most of the pages are dynamic so I'm not sure if templates > are the right way to go. > > Thanks, > Philip > > -- > Abbestellen mit Mail an: php...@li... > Kommandoliste mit Mail an: php...@li... |
From: Richard A. <rh...@ju...> - 2001-08-14 07:15:51
|
At 11:52 PM -0700 13/8/01, Philip Strnad wrote: >> supposed to be, but I have one question: does anyone use Template for >> dynamic pages or do most of you use it to "write" HTML files that are >> then served statically? Template's real strength is in simplifying the handling of dynamic pages. it allows you to write PHP code that contains no HTML -- it's all in the template files. Of course with *really* complex pages it can be a lot of work to get *all* HTML out of the code, and you'll have to decide when to stop based on a cost/benefit analysis. The best thing though is that when the boss decides to redesign the site all you have to do is re-jig your template files. In theory! >> Is there a performance impact in opening a >> template file everytime a page that uses the Template class is >> requested? I think you'll find the overhead from templates is a lot lower than the overhead from other aspects of your dynamic pages. For example, a call to preg_replace is much cheaper than the cost of bringing up a database connection. Only way to tell for sure is to try it and see :) If you do run some performance figures, be sure to post them back to the list... that always generates a lot of interest. ...R. |
From: Philip S. <ph...@st...> - 2001-08-14 07:26:32
|
> I think you'll find the overhead from templates is a lot lower than the > overhead from other aspects of your dynamic pages. For example, a call > to preg_replace is much cheaper than the cost of bringing up a database > connection. True. In my situation the db connection would already be there, so I guess the whole template processing would be negligible. So how do you do it? Are your templates parsed dynamically? > If you do run some performance figures, be sure to post them back to > the list... that always generates a lot of interest. I will see what I can come up with. I doubt I'll be getting to this anytime soon, but you never know what's going to happen since requirements change. Btw, maybe one way to speed things up would be to read the templates into memory at server startup, but I'm not sure if this is possible in PHP? I know it can be done with mod_perl, but that's totally different. Philip |
From: Richard A. <rh...@ju...> - 2001-08-14 07:54:46
|
At 12:26 AM -0700 14/8/01, Philip Strnad wrote: >the whole template processing would be negligible. So how do you do it? Are >your templates parsed dynamically? Yes, they're read in and have the content substituted on the fly. >Btw, maybe one way to speed things up would be to read the templates into >memory at server startup, but I'm not sure if this is possible in PHP? Never heard of it. Note that if you've got a busy server (and if your server isn't busy, why worry about performance ;) and the server has enough RAM, the template files will all be in cache anyway. In any event, the cost of reading in the template file is way lower than the cost of generating the dynamic content and performing the substitution. If you're using templates and databases to generate pages that are not unique *every* time (like, say a news releases page that pulls articles out of a database and is updated only every hour or so) then you can cache the built pages on disk and not even bother regenerating the dynamic content each time. You'd still need to pull a timestamp of the last inserted record out of the database but if there's no change, you can just blat out the last version of the page from cache. There was a patches that did something like this with template.inc posted by Tom Anderson to the NetUSE mailing list a long time ago. Sort of a roll-your-own Zend cache :) ...R. |