2

Is there any way opcode generated by OPcache could be loaded into OPcache without the presence of the PHP source files?

I.e. In a similar way to how APC (Alternative PHP Cache) has apc_bin_load(...) etc?

James
  • 30,496
  • 19
  • 86
  • 113
  • You mean like compiling PHP to portable bytecode? I think the correct google search-term would be _"PHP compiler"_ (loading it directly into opcode cache without any PHP code? No, that won't budge, there's nothing to validate the cached opcodes against) – Elias Van Ootegem Apr 10 '15 at 08:39
  • So... you wnat an obfuscation mechanism? – Tschallacka Apr 10 '15 at 08:40
  • possible duplicate of [Can you "compile" PHP code?](http://stackoverflow.com/questions/1408417/can-you-compile-php-code) – Elias Van Ootegem Apr 10 '15 at 08:41
  • Not as far as i'm aware, and could cause issues depending on the version of opcache that the bytecode was built against, and the version of opcache it was being loaded into – Mark Baker Apr 10 '15 at 08:41
  • Yes - I'm trying to write one and OPcache looked promising as it's shipped with PHP 5.5 upwards – James Apr 10 '15 at 08:42
  • @MarkBaker Yes I agree that would all have to be considered – James Apr 10 '15 at 08:43
  • @James: The cache is invalided if the src files that produced the cached opcodes have changed. If the files aren't there, the cache is automatically invalid (or unreachable). You'd have to rewrite the OPCache implementation of the Zend engine. Add to that the significant reduction in portability (OPCodes based on PHP versions, or other extensions being present (APC or APCu) and you'll have to conclude it really isn't worth the bother. By the time you're done PHP7 will be released, and it boasts performance similar to facebooks HHVM anyway – Elias Van Ootegem Apr 10 '15 at 08:43
  • @EliasVanOotegem Thanks for that - seems like you've answered my question! – James Apr 10 '15 at 08:44

0 Answers0