PHP WinBinder: Project

From The Uniform Server Wiki
Revision as of 18:28, 29 January 2010 by BobS (talk | contribs) (Proofreading and grammatical changes; some minor reformatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

 

UniServer 5-Nano
PHP WinBinder.

Windows Project

This page looks at creating a separate Windows application independent of Uniform Server.

Applications produced using this method are not compiled, hence are not standalone executables. They require several support files. That said, they are easy to program using PHP and Winbinder.


Project configuration

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

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

  1. Create a new folder. For example c:\project1 – Can be any name and location you like
  2. Copy folder UniServer\plugins\winbinder to folder c:\project1
  3. Copy file C:\project1\winbinder\examples\test_4.bat to folder c:\project1 – Runs your application; rename if you like
  4. Copy file C:\project1\winbinder\examples\test_4.phpw to folder C:\project1\winbinder – this folder will contain all your script files; rename file test_4.phpw if you like
  5. Delete folders C:\project1\winbinder\doc and C:\project1\winbinder\examples these are not required
  6. That completes the project structure (see image on right).

Top

Change paths

Paths in both test_4.bat and test_4.phpw need editing

Edit file C:\project1\test_4.bat

Change this line:

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

To:

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

Edit file C:\project1\winbinder\test_4.phpw

Change this line:

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

To:

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

Top

Test

Check that the configuration works by running test_4.bat

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

Top

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:

start winbinder\php\php-win.exe -c winbinder\php\php-wb.ini winbinder\test_4.phpw

When run, it will automatically close the command window and start your application.

Top

Create an EXE file

Using a batch file to start your windows application produces an annoying flicker as the command window opens and closes. This can be avoided by converting the batch file to an executable. It also provides an opportunity for personalising the file by including your own icon.

How to create EXE file

The plugin includes a powerful little utility to accomplish this. Navigate to folder C:\project1\winbinder\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 Current Directory - Where temporary files are stored - (Note: No temporary files created)
  • F) Select Delete at exit - (Note: No temporary files created)

That completes the first page set-up

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


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


Test EXE file:

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

If you wish you can delete files test_4.bat and test_5.bat. They are no longer required.


Note:

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

Top

Summary

The above has shown how to create an independent windows application project. Your PHP script or scripts can be run using an executable file however you still require all the additional support files.

If you want a single executable file, the only way to do this is compile the project. However there is an alternative! It is more a sleight of hand where you compact all the necessary files into a single executable file.

I mentioned the included utility was small and powerful; it has the ability to perform the above. To implement this method requires a flat file structure. This is covered in project 2 on the next page.

Top