Re: Optimization of PHP Code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, 2008-07-18 at 12:35 -0400, Eric Butera wrote:
> On Fri, Jul 18, 2008 at 11:43 AM, Robert Cummings <robert@xxxxxxxxxxxxx> wrote:
> > On Fri, 2008-07-18 at 16:47 +0300, Sancar Saran wrote:
> >>
> >> Do not use, template system, use inline php code for templates.
> >
> > Oh dear... you must subscribe to FUD 101.
> 
> ???
> 
> I use straight php files for my templates.  My templates are very
> strict in what they allow, but that is just a coding guideline, not an
> enforced thing.  Basically they're read only & don't contain any real
> logic.  I allow function calls, but only for things that are reads.
> Writes need to happen inside the controller.

I was responding to Sancar... there's a belief by some that template
engines are bad. Probably because they've used a template engine that
takes a run-time hit since it requires loading the template processor
and any possible cached data. This is FUD, my own template engine
compiles directly to the PHP file that will be requested by the browser
(1). It is very convenient to pre-process static information at compile
time rather than on every request (specific properties, content chunks,
content relocation, etc). Additionally, it can compile to static HTML,
CSS (2), JavaScript (3), or anything really-- in which case the PHP
intepreter isn't even needed after compile. You can't do that with a
"PHP as templating engine solution" since it always requires the PHP
engine to run. So it's FUD.

Cheers,
Rob.

(1) That's optional actually... you can use it like a traditional
template engine too... but why would you.

(2) For instance I break my CSS files into chunks when actually creating
the stylesheets. The files represent specific groupings of related CSS
and allow for embedded comments that are stripped from the final
compiled CSS file.

(3) I often use a JavaScript master template to pull in specific
javascripts into a single JavaScript file for the browser while also at
compile time normalizing whitespace and stripping comments. An
obfuscator could be added too... but I don't bother with hiding my
code :)

-- 
http://www.interjinn.com
Application and Templating Framework for PHP


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux