Hello all,

I've been thinking about PHP optimization and distribution, and I would like to hear some opinions on introducing a new feature for a future PHP 7 version. Here's the concept: allow PHP opcode to be both saved after parsing a file, and to be loaded and executed, similar to the bcompiler extension and the APC bin functions back in the day.

The advantages are clear: libraries and applications could be compiled to opcode ahead of time so PHP wouldn't have to compile it again and again (assuming you're not already using OPcache).

A new function could be provided to parse a PHP file, but instead of executing it, the compiled opcode would be saved to a file. It might part of the OPcache extension if it makes sense, and could be called opcache_compile_to_file() or something.

Another option would be to add a command-line flag to the interpreter to write compiled opcode instead of executing it after parsing.

Another part of the feature would be to enable the interpreter to execute compiled opcode scripts directly. This would work for both compiled scripts passed to the interpreter, and scripts loaded with `include` and `require`. We would probably need to introduce a new file extension to specify opcode files. I'd recommend *.phpo or *.phpc.

This is quite similar to Python's ability to execute Python scripts compiled to bytecode as *.pyc files. The feature has seen great success in Python, mostly for distributing releases of software or deploying to a server.

I'm not at this moment planning an RFC, but I'd like to gauge your opinions and reactions first.

--
Stephen

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to