Since php is so powerful, it is natural one would like to develope Windows applications with it. GUI extensions such as PHP-GTK and Winbinder allow users of the php command line interface to display GUI widgets in Windows, but the problems of distribution and code exposure still remain. The php command line interpreter must be included in any distribution, and the code is left as a text file.
There are a few open source php to EXE “compilers” out there, such as PriadoBlender and Embeder that utilize the php SAPI to include php code in executable files, but most still leave the php code plain or obfuscated in such a way that it is accessible to anyone who has a few minutes. PriadoBlender includes you code in an encrypted file, but it’s not much different than running the command line interpreter as the decryption code is exposed as plain text php inside the executable. I wanted to find something that would not allow recreation of the exact code. There are a few commercial applications out there that will do this, but they are ridiculously expensive, and inaccessible to the open source community.
In my search for a more elegant solution, I saw a few mentions of the bcompiler extension for php that seemed to do everything I wanted; it would join the code and the EXE file, and the code would be converted into php byte code, making it much harder to view and reverse engineer. The need for the php runtime DLL was still present, but that seems to be true of every php compiler, and is akin to the runtime libraries needed for Visual Basic applications.
The only problem was, you needed MS Visual Studio to compile two essential files, and only one was easily accessible. There isn’t much information on bcompiler, but eventually I found this article that mentioned the only known existing copy of the file I was looking for could be found packaged with another program by the author of bcompiler. Even when I did find the two essential files, I found they didn’t work with my php runtime, and had to use the one included in the above mentioned package.
Considering how useful bcompiler is, it’s a shame that it is so hard to obtain all of the components needed to produce usable EXEs. So now that I’ve collected all of the needed files, I’ve compiled the compiler script into a stand alone EXE. I present it as PHC, a php compiler. It is included in the PHC-SDK, which also includes the full source of PHC as well as a few simple examples to get you started, including two utilizing Winbinder to produce GUI widgets
Download the PHC-SDK with PHC v0.11 (updated from 0.1 because it seemed many people were downloading 0.1 which doesnt work in WinXP)
[UPDATE: PHC has been obsoleted by phc-win]