SwiftlyTilting: revisionist reality

Monday, March 21, 2005

PHC - A PHP to EXE compiler

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]


11 Comments Leave Comment

I’ve added a new catagory for PHC so you can easily keep track of updates :)

Comment by swiftlytilting — Wednesday, March 23, 2005 @ 5:19 am

$list = func::wb_create_control($this->mainwin, ListView, “teste”, 0, 50, 698, 260, ID_ITEMLIST, WBC_VISIBLE | WBC_ENABLED | WBC_SORT | WBC_LINES | WBC_CHECKBOXES);
wb_set_text($list, array(array(”Arquivo”,400),array(”Tamanho”,100),array(”ID”,50)));

Comment by FlycKER — Monday, June 27, 2005 @ 10:48 am

wb_set_text($list, array(array(”Arquivo”,400),array(”Tamanho”,100),array(”ID”,50)));
The system crash at this line. Why?

Comment by FlycKER — Monday, June 27, 2005 @ 11:05 am

probably because ‘wb_set_text’ is defined in wb_windows.inc but it’s not inside of a class. I need to release a new version where you dont need to have the funcitons inside of classes because it’s too cumbersome imo. right now to use winbinder fully you have to convert the existing winbinder php libraries

Comment by swiftlytilting — Monday, June 27, 2005 @ 3:12 pm

Hi,

i am looking for the php to exe program. i came to you site, which looks intresting. do you have winzip file of your program. then i can try on my xp machne. now you have tar file, which i dont have rar zip program.

thanks,
S.Sivakumar

Comment by siva — Wednesday, June 28, 2006 @ 6:36 pm

plz send me that program i mean php to exe

Comment by LASER — Wednesday, August 16, 2006 @ 8:07 am

just download a copu of www.winrar.com seek at google dot com

Comment by franco — Thursday, January 25, 2007 @ 4:03 pm

Hi,

After converting PHP file ( webpage ) to executable by using “PHC-SDK with PHC v0.11″ , is it possible to
run that executable in browser.

Please suggest.

Comment by Satheesh_SAEN — Saturday, February 10, 2007 @ 5:43 am

^ no, once it’s an EXE, you cannot use it in a web browser, only DOS/Windows

Comment by swiftlytilting — Saturday, February 17, 2007 @ 12:07 am

Hi; Before I use the brilliant software, I need to know what it would look like? I mean whole my PHP project needs to be executable, and needs browser, and should run in a LAN network, with a central MySQL server! I think it is impossible to use such a compiler for this project, right?

Thanks

Comment by Hooman Taherinia — Sunday, September 9, 2007 @ 8:15 pm

Hi Hooman,

Yes I think this is not what you’re looking for. This simply turns php code into an exe. If you need a browser and a sever and whatnot I don’t think this will work.

Comment by swiftlytilting — Monday, September 10, 2007 @ 2:28 pm

Leave a Comment

Validate XHTML | Word Press