View Single Post
Old 03-22-10, 10:31 PM   #3
t3hl33td4rg0n
Dethklok Returns!
 
t3hl33td4rg0n's Avatar
 
Join Date: Dec 2004
Location: Kent, OH
Posts: 2,142
Send a message via AIM to t3hl33td4rg0n Send a message via MSN to t3hl33td4rg0n Send a message via Yahoo to t3hl33td4rg0n
Default Re: LAMP Templating/CMS Performance

Quote:
Originally Posted by ViN86
With PHP there's only so much you can do to speed it up though.
Script compiling and code caching can speed up your applications significantly. Its not unlike databases using indexing to speed up query execution. Of course, measures like this would only be required for robust applications and where server load could become an issue.

Quote:
Originally Posted by ViN86
If you want to minimize server load, then it may be best to implement something like AJAX, where database calls are only made when necessary.
Yeah, I've considered that, and I am still considering the option. I may go both ways where the template could either grab the main dynamic data via php echo statements or retrieved using AJAX. I must still keep the mindset that I have to keep template interaction as easy as possible without sacrificing performance and feature-set.

Unfortunately, completely relying on AJAX to get data has its own issues (at least it used to). I would love to create a robust application in javascript that could allow one to freeform design a site and still harness the power of dynamic applications.

I may even integrate Dreamweaver support in some fashion by way of extensions, where a user could create custom queries using a GUI and have the usability of Dreamweavers WYSIWYG. Yes, it will rock!

Quote:
Originally Posted by ViN86
Why do you use str_replace to fill in your fields? PHP can be initiated anywhere in the page. Wherever you need the data, put in a <?php tag and echo the data, then close it ?>. That's one reason why Method II is much better. The overhead involved in searching a document for a string and then replacing it is insane.
The main reason is that anyone with HTML knowledge could create their own template/theme. just place special tags where you want the stuff to go and you're good. It was an ease-of-use feature. But that guy gave me an idea about how I could implement the other method. I never really thought about the other method (2) until i had the discussion over at devshed, thats why I wanted to have the trials and see how it stacked up.

Quote:
Originally Posted by ViN86
I always use HTML templates in my pages. Typically the header, footer, and navigation sections are always included in simple HTML templates that I include into the main page. This makes updating your site very easy, since editing 6-7 pages boils down to editing 4 short files (CSS is stored in a separate page as well).
So I am assuming you are including the dynamic data "in-between" those files? Like....

PHP Code:
$headerFile = file_get_contents('./tpl/head.html');
do
some stuff;
echo
$headerFile;
$mainTpl = file_get_contents('./tpl/main.html');
do
some stuff;
echo
$mainTpl;
Quote:
Originally Posted by ViN86
I only use file_get_contents() when I load in HTML from a separate page to parse. If you are including a functions file, always use require, so if the page is not found an error will be thrown. Could also prevent some of your page's code from being displayed.
I agree. 99.999% of the time i use require() or require_once(), I rarely use include. I go by the method, include = optional, require = required

The reason for using require() instead of file_get_contents() is because the template also has the scripts and they get executed on-the-fly. Also, its faster.

Quote:
Originally Posted by ViN86
Nice little demonstration.
Thanks!
__________________


Intel QX9650 @ 3.83GHzXFX 780ieVGA GTX 560Ti8GB GSkill DDR800Creative Sound Blaster X-Fi Titanium PCI-ESeagate 1.5TB . 4x Samsung 2TB

Quote:
Originally Posted by MowTin View Post
....it's so clear how government makes things worse not better...

Last edited by t3hl33td4rg0n; 03-22-10 at 10:33 PM. Reason: Whoopsie
t3hl33td4rg0n is offline   Reply With Quote