Archive for March, 2011

"Compiler" for PHP files


I had this problem: sites created with Tangra Framework needed long time to "boot" because  there are more than 100 chained require_once()s. On my dev server it took between about 500 and 600 milliseconds to complete which sometimes was unacceptable. To make things even worst: when used on Windows machine with XAMPP pages needed about 1200 miliseconds to complete…

Since at least  an year I had this idea: to create a "compiler" which compiles all require_once()s into one big fat file. My idea was to point the compiler to some php file which represents web page and to let it grab recursively all the required_once() files. As a result I needed a compiled version of the web page that does not contain single require_once().

Yesterday I finally decided to try to create such compiler and as of today I finally got what I desired. Comparing profiler data "before" and "after" shows 43% improvement of the compiled PHP web page (510 ms vs 290 ms) which is great. Resulting file was 12211 lines long (with about 30% empty lines). 244 calls to require_once() was eliminated.

Slow XAMPP on Windows 7 -- solution



You install brand new latest version of XAMPP on your Windows box, everything works, but PHP pages open very slow (>1 second).


Disable your antivirus software for few minutes, restart XAMPP and try again. If there is a significant improvement: the cause is your antivirus software (AV programs usually scan for viruses each accessed file which slows the apache).

If you are using Bitdefender here are the steps to configure it in a way suitable for usage of XAMPP:

  1. Simple solution -- just switch bitdefender to game mode when working with xampp
  2. "Advanced" solution -- go to Antivirus -> Shield -> Advanced Settings -> Exclusions Tab and there add exclusion for httpd.exe (located in your xampp installation/apache/bin/). Then go to Antivirus -> Exclusions and add exclusion for the directory where your php files reside.

Don't forget to restart apache after above steps.