Compiler Caching

PHP is an interpreted language. Your scripts have to be parsed and compiled into intermediate code every time your scripts are called. This includes all your include files, even if your script is just to use a tiny portion of those include files. PHP then execute the intermediate code.

Is there anywhere of speeding up your application by not having to recompile scripts every time? There is, and its called compiler caching. The idea is that PHP compiles the scripts the first time they are called. Instead of discarding the intermediate code at the end of the script, the code is cached instead. Next time the script is called, PHP executes this cached intermediate code. The more complex and bigger your code becomes, the more you can benefit from compiler caching.

There are a number of compiler caches available. The Zend Accelerator is a commercial compiler from Zend Industries, the producers of the PHP engine.

APC (Alternative PHP Cache) is a free open source compiler available from Pear. In theory,installing should be straight-forward if you have got pear installed:
$ pecl install apcon the command line.

I tried this on a Windows machine, and got the error message "Error: The DSP APC.dsp does not exist"

Next I tried extracting the APC .tgz package, and moving the package.xml file into the same folder as the source (.c and .h) files where the apc.dsp file is. I tried installing using:
pecl install path/to/source/package.xmlThis might have worked, but I needed to have the php source files as well.

What you can do on a Windows machine is get the Windows binary (php_apc.dll) and the script apc.php from Justin or from php.net. The later does not include the apc.php file - so you will have to get it from the .tgz package at PECL APC.

Justin gives you further instructions on how to set yourself up. I will give this a try another day.

Back to top