SwiftlyTilting: usability, reusability

Monday, March 21, 2005

PHC - A PHP to EXE compiler

UPDATE: PHC has been obsoleted by phc-win

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

28 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


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.


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


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?


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

Hi can this exe file will conncet with mysql database ?

Comment by Naveen — Wednesday, May 28, 2008 @ 10:00 pm

It should.. if not perhaps you can use sqlite?

Comment by swiftlytilting — Tuesday, July 1, 2008 @ 3:10 pm

How bout post/get variable? Its translated into parameter or input stream or what?

Comment by singaa — Friday, December 19, 2008 @ 12:40 am

Post/get are only available when PHP is used with a web server…

Comment by swiftlytilting — Tuesday, December 23, 2008 @ 1:50 am

It cant be used to convert php from a web bussiness that already run? If yes, it isnt what im looking for… Btw, tq for your explanation

Comment by singaa — Monday, January 5, 2009 @ 12:07 am

No it’s not for converting web applications to EXE, it’s for writing Windows specific applications. See Winbinder.org for more information on making Windows programs in PHP. :)

Comment by swiftlytilting — Monday, January 19, 2009 @ 7:30 pm

I want to change the exe icon before compilation beacause it’s always php icon. How l do that please ?

Comment by Dominique — Tuesday, March 10, 2009 @ 8:51 am

Can I use this to compile PHP into a DLL? I want to bind PHP code to an executable written in C++, and the easiest way would seem to be though a DLL.

Comment by Brian — Thursday, March 19, 2009 @ 6:16 pm

@Dominique, you should use a program called a resource editor. it allows you to edit the various files stored in the exe

@Brian, unfortunately, no, it cannot compile a DLL. We are limited to the functionality of bcompiler which does not offer the ability to make DLLs

On a side note, win32std will no longer be needed in the planned upgrade version, which means phc-win will work with the latest verion of php. Unfortunately no planned release date for this version yet.

Comment by swiftlytilting — Wednesday, April 15, 2009 @ 6:32 pm

this is my dream!
thank you swiftlytilting
now i get rid of visual basic and write my applications in php.
php really is a powerful language.

بروبچز ایرونی دانلود کنید حالشو ببرید :دی
این نهایت رویای شماست.
بشینید باهاش دسکتاپ اپلیکشن بنویسید
پی اچ پی زبان ساده و قدرتمندی هست.
با همون ریگولار اکسپرشن هاش میشه تکست پراسسینگ هایی نوشت که عالم در عجب بماند.
وی بی رو هم دیگه ول کنید بزارید یکم نفس بکشه بیچاره خسته شده هنوز توی مدارس وی بی 6 درس میدن!! دست از سرش بردارین دیگه :دی

sorry dudes. i wrote some lines in my language for my country’s folk.
thanks in advance!

Comment by Saeed — Friday, April 17, 2009 @ 5:26 am

Fantastic job, thank you for sharing it!
I need to use a newer version of php5ts.dll (version compared with that you provide now) in order to embed the sql server driver php_sqlsrv_ts.dll provided by microsoft.
I tried to replace old php5ts.dll with the version but phc-win will not start.
Can you give any clues what other files need updates to make this work?

Comment by Gabriel — Monday, May 4, 2009 @ 1:41 pm

Hi there,

i am just wondering if this compiler can protect my original php code. also will it work with php cURL library ?

Comment by web extraction — Monday, May 4, 2009 @ 11:13 pm

@Gabriel: Unfortunately winstd.dll does not work with newer versions of PHP, and the developer isn’t updating the library any more. I know how to work around it, but I have not implemented it yet.

@web extraction: it doesn’t “protect it” but it does convert the code to php bytecode which can theoretically be converted back to some kind of source code. But it’s not raw text or anything like that.

Comment by swiftlytilting — Sunday, May 24, 2009 @ 1:56 am

Super work well done. Thanks very much, I can see the potential. All for free too.

Peace :)

Comment by mits — Friday, December 4, 2009 @ 10:59 am

Thanks Mits :) Be sure to notice PHC is now replaced by phc-win

Comment by swiftlytilting — Friday, December 4, 2009 @ 10:35 pm

men this is cool stuff.i need the procedure,thanx.

Comment by bismark — Friday, June 10, 2011 @ 1:54 am

Fantastic job, thank you for sharing it!
I need to use a newer version of php5ts.dll too

Comment by wordpress website hosting — Thursday, December 1, 2011 @ 6:14 am

Leave a Comment

Validate XHTML | Word Press