PHP WinBinder 2: PHC-Win

From The Uniform Server Wiki
Jump to: navigation, search
PHP WinBinder 2 :  Introduction | WinBinder portable | Add code | PHC-Win | Resource

 

Contents

UniServer 5-Nano
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.

Preliminary work

PHC-Win packages files that are contained in a folder and its sub-folder. Any files outside this structure are not accessible and 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:

  • winbinder.php
  • wb_windows.inc.php
  • wb_resources.inc.php
  • wb_generic.inc.php

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, so 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

To

Include "winbinder.php";       // Location Of Winbinder Library

That completes the provisional work. Test your application before proceeding by running the batch file C:\us_wb\my_app\z_basic.bat

Run PHC-Win

  • Navigate to folder C:\us_wb\phc
  • Double click on file phc-win.exe
  • This opens the main window
  • A) Select File > Compile Directory





  • B) Navigate to folder my_app highlight it
  • C) Click Ok







  • D) Click on file z_basic.phpw
  • E) Click Open






  • F) Wait for it to complete compiling
    at the pop-up click Yes
    selects windows application
  • The process is complete click Ok

WinBinder FE 4.gif


All PHP files are compressed.
Resulting files have a phb extension.


These files and resources are
assembled into a final exe file.


You will see an output similar
to that shown on the right.

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 the distribution package

The 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.

The reason for two folder levels is purely for testing. It will highlight attempts to access files outside of our flat structure.

Build the Distribution

  • 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 so 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

Test

Perform a quick test by double clicking on file C:\us_wb\my_dis\final\z_basic.exe

That’s it! Confirm your application runs, then zip folder final and distribute.

Top

Summary

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. The next page shows how to resolve this.

Top


Personal tools
Namespaces

Variants
Actions
Navigation
Toolbox
Uniform Server