Do Vanilla / plugins work with php compilers?
I am curious whether any of the php compilers would work with Vanilla. I am thinking of compiled plugins, an idea initially raised by someone in my work (I'm running a private forum in our intranet). While I understand that this might run against the grain of open source I am interested in answering the question and considering what would it take to make this happen.
One hurdle I can think of is the plugin description array that is parsed by Vanilla. Somehow that has to be excluded from the compilation. Perhaps a wrapping plugin that invokes the compiled php code would do the trick.
I have never worked with a php compilers, I presume they create executable (with possibly some runtime library available at runtime) which can be invoked by standard php. There may even be performance advantages to compiled code though I suspect these would be nullified by the need to interface with the rest of the code.
Anyway, I appreciate your thoughts on this.
Comments
As far as I know, HHVM is the most popular PHP compiler, but PHP 7 also works with JIT compiling. @x00 tested HHVM: https://vanillaforums.org/discussion/comment/200014#Comment_200014
Vanilla now is (tested with PHP 7)[ https://vanillaforums.org/discussion/31086/vanilla-is-adding-unit-tests-and-travis-ci
and as soon as Vanilla is 100% compatible with PHP 7, there might be no use for any additional compilers: https://kinsta.com/blog/hhvm-vs-php-7/
Thanks! What about distributing compiled code (not jit)?
Continued - thanks again for the insightful links. I learned that from the performance point of view HHVM and php 7 are very promising. Looks like HHVM is not a simple setup (which is fine).
I am still curious about the obfuscation issue - what would it take to distribute compiled plugins given that Vanilla parses the source description array and invokes the plugin through the fire event function...
"Executables" in PHP are called extensions. For Windows they come as .dlls and for Linux you get .so files. They must be specified in the php.ini of your server.
Although you have to have a plugin file, you should be able to use a compiler that creates an extension you can install on the server. For the installation, it must be included in the php.ini file. I guess it could still be located in your plugins folder, if that is important.
Your plugin would only have to implement the PluginInfo array and the class definition that extends your class from your extension. So it comes down to three files: a "stub" of a normal Vanilla plugin and the binaries for Linux and Windows.
Doing a quick search for compilers, I found this one which has at least a very promising description: https://github.com/jimthunderbird/php-to-c-extension
It is based on Zephir and if you really consider to go in the direction of creating binaries, I personally would use it: http://zephir-lang.com/
The only thing I'm really unsure about is how easy it is to call "external"/Vanilla functions. I assume a
$value = val($needle, $haystack);
would lead to a compile error.Thank you @R_J. I learn a lot from you! (and others too). I can't believe the amount I learned since I started a while ago as a part time interest with no previous exposure to php, css, Vanilla, and other things (I did not program for more than 20 years and even that was in an entire different universe...). Just wanted to express a HUGE gratitude to you all.
How can I include the .dll file with this product.