PHP WinBinder 2: PHC-Win
PHP WinBinder 2.
WinBinder Part 2 PHC-Win
After completing a project you will want to package and distribute it. An excellent application for this task is PHC-Win written by Andrew Fitzgerald (WinBinder Wiki name Frantik). It is essentially a click and go program however a small amount of preliminary work is required before running this program.
The tutorial assumes you have extracted a copy of PHC-Win as explained on this page.
PHC-Win packages files that are contained in a folder and its sub-folder.
Any files outside this structure are not accessible hence will not be packaged.
Our application folder C:\us_wb\my_app uses four files that are outside of this structure.
These are the four WinBinder files:
Copy these files from folder C:\us_wb\wb\php\include to your application folder.
For this tutorial copy them to folder C:\us_wb\my_app
Our application needs to pick these up hence a single line requires changing
Edit file C:\us_wb\my_app\z_basic.phpw (your application) Change this line
Include "../wb/php/include/winbinder.php"; // Location Of Winbinder Library
Include "winbinder.php"; // Location Of Winbinder Library
That completes the provisional work test you application before proceeding by running the batch file C:\us_wb\my_app\z_basic.bat
Compiling C:\us_wb\my_app Compiling: button_1_toggle.inc.php --> button_1_toggle.inc.phb... done Compiling: button_2_toggle.inc.php --> button_2_toggle.inc.phb... done Compiling: green_1_on.inc.php --> green_1_on.inc.phb... done Compiling: green_2_on.inc.php --> green_2_on.inc.phb... done Compiling: red_1_on.inc.php --> red_1_on.inc.phb... done Compiling: red_2_on.inc.php --> red_2_on.inc.phb... done Compiling: wb_generic.inc.php --> wb_generic.inc.phb... done Compiling: wb_resources.inc.php --> wb_resources.inc.phb... done Compiling: wb_windows.inc.php --> wb_windows.inc.phb... done Compiling: winbinder.php --> winbinder.phb... done Compiling: z_basic.phpw --> z_basic.phb... done Done compiling. Creating new exe: z_basic Setting C:\us_wb\my_app/z_basic.phb as main file in z_basic Adding C:\us_wb\my_app/button_1_toggle.inc.phb as ./button_1_toggle.inc.php Adding C:\us_wb\my_app/button_2_toggle.inc.phb as ./button_2_toggle.inc.php Adding C:\us_wb\my_app\green.bmp as ./green.bmp Adding C:\us_wb\my_app/green_1_on.inc.phb as ./green_1_on.inc.php Adding C:\us_wb\my_app/green_2_on.inc.phb as ./green_2_on.inc.php Adding C:\us_wb\my_app\red.bmp as ./red.bmp Adding C:\us_wb\my_app/red_1_on.inc.phb as ./red_1_on.inc.php Adding C:\us_wb\my_app/red_2_on.inc.phb as ./red_2_on.inc.php Adding C:\us_wb\my_app\uslogo.ico as ./uslogo.ico Adding C:\us_wb\my_app/wb_generic.inc.phb as ./wb_generic.inc.php Adding C:\us_wb\my_app/wb_resources.inc.phb as ./wb_resources.inc.php Adding C:\us_wb\my_app/wb_windows.inc.phb as ./wb_windows.inc.php Adding C:\us_wb\my_app/winbinder.phb as ./winbinder.php Adding C:\us_wb\my_app\z_basic.bat as ./z_basic.bat Done creating EXE.
Create distribution package
Final part of the process is to create a distribution package. This requires copying all the required files into a folder.
Inside folder C:\us_wb, create a new folder named my_dis (any name you like). Inside this create another folder named final (again any name you like). You can always use a folder outside of us_wb.
Reason for two folder levels is purely for testing. It will highlight attempts to access files outside of our flat structure.
- First copy the executable C:\us_wb\my_app\z_basic.exe to folder C:\us_wb\my_dis\final
PHC-Win compiles only the PHP files hence any images used need to be copied
- Copy uslogo.ico to folder C:\us_wb\my_dis\final
- Copy green.bmp to folder C:\us_wb\my_dis\final
- Copy red.bmp to folder C:\us_wb\my_dis\final
In order to run our application the following core binaries are required.
From folder C:\us_wb\phc copy the following files to folder C:\us_wb\my_dis\final
- php-embed.ini - Php configuration file list modules for php
- php5ts.dll - PHP core
- php_winbinder.dll - WinBinder module
- php_win32std.dll - Windows standard api
- php_bcompiler.dll - Bam compiler
Perform a quick test double click on file C:\us_wb\my_dis\final\z_basic.exe
That’s it, confirm your application runs then zip folder final and distribute.
In my original write up I implied compiling was difficult. After making a few minor changes to your code using PHC-Win all it takes is a few mouse clicks.
We added images to our final distribution package however take a closer look at what is added to the exe file! PHC-Win adds these and any other files contained in our application folder. This duplication is not required next page shows how to resolve this.