SwiftlyTilting: revisionist reality

Tuesday, March 7, 2006

phc-win 0.2.1 - bugfixes

As expected, there were some bugs with the first release of phc-win. The biggest problem occured whenever the path of the program file or any code contained a space: it simply wouldn’t compile the code. That has been fixed in this version. Some other minor bug fixes as well.

phc-win 0.2.1 rar archive
Downloaded 2488 times
phc-win 0.2.1 upgrade rar archive
Downloaded 378 times
For the latest version, check the phc-win category.

Monday, March 6, 2006

phc-win: A PHP compiler for Windows

PHC-WIN is a windows application that allows one to create EXEs from PHP code. The PHP code is first converted to PHP bytecode using bcompiler, and then embedded into an EXE using embeder. Compiling the code into bytecode has two benefits: it speeds up load times since the PHP code doesn’t have to be interpreted, and it obfuscates the code so that it cannot be easily reverse engineered.

PHC-WIN itself is written in PHP and utilizes wbObjects, my object oriented layer for WinBinder to create windows controls.

PHC-WIN Wiki page with documentation

Download:
phc-win 0.2.0 rar archive
Downloaded 483 times
phc-win 0.2.0 self extracting exe
Downloaded 559 times
For the latest version, check the phc-win category.
keywords: php to exe, php2exe

Wednesday, March 23, 2005

PHC update

Well it looks like there was a major problem with the first release of PHC; it only worked correctly in Windows 98! I’ve fixed it to work correctly in WinXP, and also streamlined the console/window program type selection.

PHC-SDK v0.11

[UPDATE: PHC has been obsoleted by phc-win]

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]

Validate XHTML | Word Press