Compiling standalone PHP-GTK2 applications on windows using PriadoBlender
Written by kksou   
Monday, 21 July 2008

This article contains step-by-step instructions on how to set up and compile standalone PHP-GTK2 applications into .exe files on windows using PriadoBlender.

Interestingly, installing PriadoBlender and compiling the PHP-GTK2 apps is the easy part. The "tricky" part is how to distribute and run the compiled .exe.

Important Note: For now, PriadoBlender only works with the Gnope version of PHP-GTK (which is running PHP-GTK2 alpha version with PHP v5.1.4 and GTK+ v2.6.9). I'm sure the author of PriadoBlender will upgrade the program soon to work with PHP-GTK v2.0.


Installing PriadoBlender

  1. Download PriadoBlender-2.0 BETA.zip. Note that this zip file is huge, about 23.1MB.
  2. Unzip the file anywhere you like. You will see a folder called "PriadoBlender".
  3. That's it! You're now ready to run PriadoBlender!

Using PriadoBlender

  1. Go to the folder where you have unzipped PriadoBlender.
  2. From the root directory of PriadoBlender, you will see a folder called bin. Open this folder. You will see a file called main.exe. Make a backup copy of this file. You can just click on the file, and then press Ctrl-C (Copy) followed by Ctrl-V (Paste).
  3. I'll explain more about why the need to do this later. For now, just go ahead and make a backup copy of this main.exe somewhere.

  4. Now double click the file PriadoBlender.exe (located in the root folder). You will see the following:
  5. Select "File - New Project" from the menu as shown below:
  6. Select your output name, input file and output folder. For Type of Project, select "PHP-GTK2". For Version of PHP, select "PHP5". When you're ready, click Compile!
  7. If everything goes fine, you will see the following message:
  8. Congratulations! You've successfully compiled your PHP-GTK2 application! Using the example above, you should now see the file sample-code-0033.exe in the output folder you have specified.
  9. Note that if you double-click on the .exe file now, most likely your program will start. However, I find that 9 out of 10 times, when you start clicking somewhere in the program, the program will quit. Please read on to see how to resolve this.

Distributing and Running the Compiled Application

This is the most "tricky" part so make sure you follow the steps.

PriadoBlender actually comes bundled with PHP-GTK2 alpha running on PHP v5.1.6 with GTK+ v2.6.9. However, I find that the bundled PHP-GTK2 doesn't run properly most of the time.

I found out that the compiled program works pretty well with the Gnope version of PHP-GTK2. The Gnope version is running PHP-GTK2 alpha with PHP v5.1.4 and GTK+ v2.6.9.

So assuming you're application runs fine with the Gnope version of PHP-GTK2, to distribute your application:

  1. Install a copy of the Gnope version of PHP-GTK2 on your machine. Note that it's fine to have the Gnope version co-exists with PHP-GTK v2.0 or v2.0.1.
  2. Make sure your application runs fine with the Gnope version of PHP-GTK2.
  3. Compile your PHP-GTK application as outlined above using PriadoBlender.
  4. Make a copy of the entire folder of the Gnope version of PHP-GTK2. Rename the duplicated folder. Let's suppose you have renamed it as app1.
  5. In the folder where you have compiled your application, using the example above, copy the file sample-code-0033.exe (i.e. your compiled application) and the folder bin into the folder app1 (i.e. the Gnope version of PHP-GTK2 which you have duplicated).
  6. That's it! The folder app1 is all you need to distribute your program. To run your application, double-click on sample-code-0033.exe (i.e. the compiled .exe file.) And, of course, you can use some installer application to package this folder into a setup.exe.

How to recompile your application

If you have successfully used PriadoBlender, I'm sure one of the immediate questions you'll ask is how to recompile the application?

When you first run PriadoBlender, the following screen appears:

But when you run it the second time, your compiled application will run.

So if you need to recompile your application, how do you do that?

This is the reason why I asked you to make a copy of the file main.exe in the folder bin above.

When PriadoBlender compiles your application, the compiled application will overwrite this file main.exe. To recompile your application, just copy back the original main.exe (make sure you rename it back to main.exe), and you will see the compile screen again!

User reviews

There are no user reviews yet.

Note: You have to be a registered member to leave a comment. Free registration here.

Last Updated ( Monday, 21 July 2008 )
 
Next >

Copyright © 2006-2008. kksou.com. All Rights Reserved