Open terremoth opened 3 years ago
You can create small programm in C and attach to end of exe file archive with PHP interpreter and your PHP scripts. You programm shoud unpack archive from itself into temporary dir and execute PHP
You can create small programm in C and attach to end of exe file archive with PHP interpreter and your PHP scripts. You programm shoud unpack archive from itself into temporary dir and execute PHP
Have you done this before?
It could be possible to compile it using something like PeachPie. I haven't tried compiling anything written with this library just yet, but since it doesn't require a new PHP extension and appears to rely on IPC, it should work just fine provided the other dependencies are with it the finished product (and where the library expects them)
It may provide you with a few more files than a single standalone EXE though, but maybe significantly less than what you're working with if you're asking to compile them together.
Another option could be a PHAR archive (a good compiler for these is box), which essentially ZIPs all your project files and dependencies into a single archive, slaps a PHP stub script in front of the ZIP header, and then calls it a day (I'm simplifying a bit). Essentially you end up with one file that contains your application, libraries, and dependencies that is callable just by doing php path/to/phar.phar
, which would totally be scriptable via a batch file. Though I assume you'd like to avoid including the PHP interpreter itself outside the compiled file since you were asking about it being a standalone executable.
To add to what other have siad, there is also rapidexe but it will work only on windows. You can manually bundle your runtime so even if its a touch old, it will work with any php version/config (or other runtime) you need.
Is there a way to do this?