PHP WinBinder: Project2

From The Uniform Server Wiki
Jump to navigation Jump to search


UniServer 5-Nano
PHP WinBinder.

Windows Project 2

The Bat2Exe Converter from Fatih Kodak is a very solid utility that offers more than its name implies. One neat feature is its ability to compress and add extra files to the .exe created.

This combined with WinBinder’s flexibility allows you to produce a Windows application coded in PHP without the need for compiling. An entire windows project can be distributed and run as a single (exe) file.

Project configuration

For quickness I will use example 4 as a template for the new application.

In order to package files into a single .exe requires the file structure be flat. In this respect, WinBinder places no restrictions. Just copy the files to a single folder and change paths accordingly. This step-by-step guides explains how.

I have assumed you installed the plugin to Uniform Server's plugin folder.

  1. Create a new folder for example c:\project2 – Can be any name and location you like
  2. Copy the entire contents of folder UniServer\plugins\winbinder to folder c:\project2
  3. Delete folder C:\project2\doc
  4. Move file C:\project2\examples\test_4.bat to folder C:\project2 - This runs your new script
  5. Move file C:\project2\examples\test_4.phpw to folder C:\project2 - This would be your new script
  6. Delete folder C:\project2\examples
  7. Move file C:\project2\php\libeay32.dll to folder C:\project2
  8. Move file C:\project2\php\php5ts.dll to folder C:\project2
  9. Move file C:\project2\php\php.exe to folder C:\project2
  10. Move file C:\project2\php\php-wb.ini to folder C:\project2
  11. Move file C:\project2\php\php-win.exe to folder C:\project2
  12. Move file C:\project2\php\ssleay32.dll to folder C:\project2
  13. Move file C:\project2\php\include\ to folder C:\project2
  14. Move file C:\project2\php\include\ to folder C:\project2
  15. Move file C:\project2\php\include\ to folder C:\project2
  16. Move file C:\project2\php\include\winbinder.php to folder C:\project2
  17. Delete folder C:\project2\php
  18. That completes the project structure.


Change paths

Paths need to be changed for the new flat structure:

File   Old Path   New Path
Include "../php/include/winbinder.php";
Include "winbinder.php";
..\php\php.exe -c ..\php\php-wb.ini test_4.phpw
php.exe -c php-wb.ini test_4.phpw
extension_dir = "./extensions"
extension_dir = "./"

top | Top]]


Check that the configuration works by running test_4.bat

You now have a working project template. Use this to develop your application.


New batch file

After completing your application create a new batch file named test_5.bat (or any name you like) with the following content:

php.exe -c php-wb.ini test_4.phpw

When run, it will automatically close the command window after application is closed.


Create a single EXE file

The following step-by-step guide explains how to package all required files into a single executable.

How to create a single EXE file

Navigate to folder C:\project2\bat2exe and double click on file Bat_To_Exe_Converter.exe

  • A) Select options tab
  • B) Click button to right and navigate to the batch file to be converted. Select the file and click open.
  • C) The path and name of the executable is automatically generated. Change the file name if you wish.
  • D) Select Invisible application
    This hides that annoying flash by hiding the command window.
  • E) Select Temporary Directory - Where temporary files are stored - (Note: These are the additional files included)
  • F) Select Delete at exit - (Note: deletes additional files a cleanup operation)

That completes the first page set-up

Bat2exe 3.gif

  • G) Select include tab
  • H) Click Add button. With the exception of the two batch files, select all files in folder C:\project2.

Note: Depending on your application there may be resource files, include scripts and images these all need to be included.

Bat2exe 4.gif

Note: Steps I) and J) are optional and only required if using an icon for the .exe file.

  • I) Select Version information tab
  • J) Click button to right and navigate to the icon file you wish to use. Select the file and click open.
  • K) Click Compile button.
    A compile pop-up is displayed. Wait for this to close.
  • L) After the compile pop-up closes click Exit

Test EXE file:

Navigate to folder C:\project2 and double click on the file created test_5.exe

You can now distribute this single file or use as if it was a compiled.

Note: It appears to initially run slower this is because all additional files are decompressed and extracted to a temporary folder before the application is run.

Note 1:

If you like filling in forms you can add version details.

Note 2:

Project folder size is 7.58 MB and executable compresses to 2.59 MB. This is reasonable for an un-compiled windows application.

Bat2exe 5.gif



I have shown how to use this plugin independently of Uniform Server. It allows you to create Windows applications that are coded in PHP without the need for any compiling.

With this plugin installed to UniServer’s plugins folder it allows you to tap into 5-Nano’s control core. The advantage of this is that you can create a Windows application to provide an alternative control interface.

More importantly you can tailor an application to meet your specific requirements.

UniController from UniServer 4-Mona series remains a popular control interface and makes an ideal vehicle for explaining programming techniques involved in producing an alternative controller.

The remaining part of this tutorial covers UniController for the 5-Nano series. See next page for an introduction.