[Compiler-Construction] Convert a PHP script into a stand-alone windows executable



Answers

I tried most of solution given in the 1st answer, the only one that works and was non-commercial was php-desktop.

I simply put my php files in the www folder, chaged the name of .exe and i was able to run my php as an exe !!

Also there is a complete documentation, up to date support and options can be easily changed.

Unfortunately most of the 1st answer's project have been discontinued and it is hard to find the perfect way to do that is also cross platform...

Question

I want to automate a fairly simple task. For this I have written a small PHP script which I run from the command line using PHP-CLI. Now I want to hand over this script to someone but I do not want to:

  • give away the source code
  • ask him to install PHP on the system

Is there a way to create a .exe version of the PHP script. I am really not much worried about de-compilation; I am more worried about asking people to install and configure PHP.




My experience in this matter tells me , most of these software work good with small projects .
But what about big projects? e.g: Zend Framework 2 and some things like that.
Some of them need browser to run and this is difficult to tell customer "please type http://localhost/" in your browser address bar !!

I create a simple project to do this : PHPPy

This is not complete way for create stand alone executable file for running php projects but helps you to do this.
I couldn't compile python file with PyInstaller or Py2exe to .exe file , hope you can.
You don't need uniformserver executable files.




I had problems with most of the tools in other answers as they are all very outdated.

If you need a solution that will "just work", pack a bare-bones version of php with your project in a WinRar SFX archive, set it to extract everything to a temporary directory and execute php your_script.php.

To run a basic script, the only files required are php.exe and php5.dll (or php5ts.dll depending on version).

To add extensions, pack them along with a php.ini file:

[PHP]
extension_dir = "."
extension=php_curl.dll
extension=php_xxxx.dll
...



Try PHPFlexer

Based on phc-win, I've made a solution for command line programs (that is, if you don't want to do a lot, just make an exe out of your php), currently it only supports a single file without even include() or require() but it's still quite useful:

http://deneskellner.com/sw/phpflexer

Works like a compiler (it's not really a compiler), a quick solution for exactly the problem described above. Again, one single php file goes in, one standalone exe comes out. Feel free. And thanks for Jared / phc-win.

Some examples included to see what you can do.




Links