20

I have a command line php app that I need to distribute to a client. I just want to give them an executable, not instructions for installing php ;)

What is a good php compiler for windows that includes support for php 5, curl, TLS, and a few other libs I use?

I need to control memory and time limit usage, so I must be able to use a custom php.ini. (this should be packaged in the exe as well, not a separate file)

Additionally, I don't want the code to be easily extracted. This isn't a huge requirement, but I'd rather not have the source viewable in a hex editor.

I've got a few hits on Google, but if anyone has actually used one, your feedback would be invaluable.

edit

If I knew I was going to distribute this to the client when i started, I'd have used C#. But I didn't. Now they want to buy it. It needs to be DEAD SIMPLE. one executable containing the php interpreter and my script plus an entry point to start my script when the exe is run.

It would also be great if I didn't have to redistribute dll's either.

edit2

I am look for somthing along the lines of phc, or roadsend. phc doesn't support windows, and roadsend doesn't support php5 in windows.

Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168

3 Answers3

20

Okay I figured it out. there is a open source program called phc-win. It supports php 5.3.1, compiles scripts to byte code (obfuscation!) and is simple to use (It even has a gui).

It needs a php-embed.ini and whatever DLL's you use, but it just works.

Thanks for all the answers everyone!

phc-win 0.3.1 (c) 2009 Andrew Fitzgerald - contact@swiftlytilting.com PHP Version: 5.3.1

  • To compile a single file:

    • Choose 'Compile single file' from the File menu.
    • Then select the file to compile.
  • To build an EXE containing all files in a directory and all sub directories:

    • Choose 'Compile directory' from the File menu.
    • Select the project folder.
    • Select the main program file.
    • phc-win will then recursively scan the specificed directory.
    • All files with 'php' anywhere in the extension will be compiled into .phb files.
    • These .phb files, along with all files in the directory tree will be added to the project EXE.

    • Once the EXE has been created, you will be asked about the EXE type:

      • CONSOLE (displays DOS box)
      • WINDOWS (no DOS box).
  • Place the EXE in the same directory with the required DLL file(s) and php-embed.ini file if needed.

Byron Whitlock
  • 52,691
  • 28
  • 123
  • 168
  • Your problem is identical to mine. The difference is I knew I was going to give it away, but Seeing how this project is on demand now, I want to prevent clients from copying it. I am currently using Wamp(because this is what our school taught us to use), and have not setup Apache server and PHP myself before. If compiled, will it still work with wamp? – Jomar Sevillejo Feb 26 '14 at 05:35
  • You may want to check out ZZEE PHPExe. However, the way to do protect your product is to have your program initially send to a central database the MACID of the machine it is run on and then have it periodically check which MACID is valid and stop if the current MACID it is running on is no longer valid. This makes it so multiple copies can be given out but only one will work at a time. Sort of torques around someone who gave out copies. Be sure to include a way to reset everything so the original owner can be forgiven. (Like new download has new internal ID number and old ID is disabled.) – Mark Manning Dec 09 '15 at 14:10
  • Based on phc-win, there's a tool called PHPFlexer (http://www.softpedia.com/get/Programming/Debuggers-Decompilers-Dissasemblers/PHPFlexer.shtml) which makes it very easy to compile and produces a standalone (and portable) EXE. – dkellner Jan 09 '18 at 16:30
7

You want this: Bamcompile

http://www.bambalam.se/bamcompile/

You can use the WApache, too:

http://wapache.sourceforge.net/

And, if none of these options satisfy you:

http://www.zzee.com/phpexe/

Paulo Coghi
  • 13,724
  • 14
  • 68
  • 90
  • ZZEE PHPExe is exactly what I want. Too bad it costs $200. Thank you. – Byron Whitlock Jul 06 '10 at 19:13
  • 3
    if they want it, charge them the extra $200, and get a tool for free. – Zak Jul 06 '10 at 19:31
  • 1
    I have used Bamcompile extensively at a previous job, but I had to work my code around it's limitations. ZZEE sounds great, and I think $200 is quite fair for the tool which will enable secure distribution of your application... The cost of doing business, friend. – Fosco Jul 06 '10 at 19:43
  • 1
    Now ZZEE PHPExe costs $99 xD – Paulo Coghi Feb 13 '13 at 22:14
1

If you want to run php scripts as Windows executable, the best is Wapache http://sourceforge.net/projects/wapache/ and if you want to protect your code try ZZEE