Simple PHP opcode caching solution which does not need compilation?

1.5k views Asked by At

I have a PHP site where all pages include an 57K generated PHP file. I'm thinking of using an opcode cache, so the file doesn't need to be parsed for every time a page is loaded (I assume loading the already parsed file would be faster than reading the 57K source file).

APC seems to be good candidate for this, but according to phpinfo my Godaddy shared hosting doesn't have it compiled in and I can't compile and install it in a shared hosting enviroment. The Zend framework is installed, but according to the docs it also needs APC or an other opcode cache as a backend.

What other options do I have to perform opcode caching? Is there a PHP-only opcode caching solution which I could simply FTP to godaddy?

2

There are 2 answers

2
Powerlord On BEST ANSWER

Is there a PHP-only opcode caching solution which I could simply FTP to godaddy?

Unfortunately, no. By the time a .php file runs, it's already too late as the interpret and compile actions have already been performed.

Therefore, it must run as a PHP extension, which are compiled...

0
Pascal MARTIN On

Reading a file PHP file, parsing it, compiling it to opcodes, and executing the opcodes, is all done internally by the internal PHP engine -- which means a PHP script has absolutly no control over this process ; and which also means the only way to alter that process is via a PHP extension (PHP extension means an extension developped in C), which have a much higher level of control.

This means there is no way to get an opcode-cache developped in pure-PHP : opcode manipulations, compilation, and caching are operations you cannot control from PHP.

And as PHP extensions have access to the internals of the engine, only administrators of the server can install and enable them -- considering they can crash PHP, eat up any amount of memory they want, you can probably understand why.

So, unfortunatly, there is not much hope for you : if you want to use an opcode cache like APC, you'll have to go with some hosting service that provides it -- which might mean using your own dedicated server.