Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Way to compile php file and create standalone .exe so others can execute #189

Open
terremoth opened this issue Jul 12, 2021 · 4 comments
Open

Comments

@terremoth
Copy link

Is there a way to do this?

@lostcodder
Copy link

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

@terremoth
Copy link
Author

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?

@ShadowEO
Copy link

ShadowEO commented Apr 27, 2022

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.

@DubbaThony
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants