"Compiler" for PHP files

Posted / Публикувана 2011-03-16 in category / в категория: Tangra framework for PHP

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.

Comments are closed.