Running WinBinder applications

Associating the PHPW extension with WinBinder

To run WinBinder scripts for Windows Explorer you have to associate .phpw files with php-win.exe. You can accomplish this in several ways.

Option 1: automatic installation

If you use the WinBinder installer (available at the web site), this will be done automatically for you. To run a WinBinder script, just double-click the respective .phpw file.

Option 2: manual association

To manually associate the .phpw extension to php-win.exe, follow the steps outlined in the Windows Help under the topic "associating extensions with file types". Be sure to create an action named open and associate it with php-win.exe followed by "%1" (with quotes). Example: C:\WinBinder\PHP\PHP4\php-win.exe "%1". Alternatively, in Windows 2000 or Windows XP you can right-click or the .phpw file and select "Open With..." to perform the same action. Now you may execute a PHPW script just by double-clicking it.

Option 3: Windows Registry

You may also add entries in the Windows registry. This procedure, however, is recommended for advanced users only and is beyond the scope of this documentation.

Running WinBinder without a console window

The console (DOS) window is quite useful to display debug information while you are developing an application. For distribution or for regular use, however, you may prefer to disable it. Follow the steps below:

  1. Use php-win.exe instead of php.exe.
  2. Optionally associate .phpw files with php-win.exe (see above).
  3. Suppress all your output: remove all occurrences of echo(), print(), printf(), print_r() and other such functions from your scripts. If you do not do that, your script may not run at all. You may include an early call to ob_start() instead as a handy way of suppressing all output.
  4. Suppress errors: use error_reporting = 0 in PHP.INI. If you do not do that, your script may not run at all with php-win.exe.
  5. Optionally use display_errors = Off in PHP.INI. If you set error_reporting = 0 this is not necessary.

Running scripts from your favorite code editor

In addition to using your favorite code editor to edit WinBinder scripts, you may want to use it to run them. The descriptions below apply to two widely used text editors, but the procedure should be similar to most others. Consult your editor documentation for details.

  1. The first step is to create a new setting for running PHP scripts. In TextPad, you must open the Configure / Preferences / Tools and add a new Program. In PSPad, you must create a new project, save it, and go to Projects / Project Settings / Compiler.
  2. The new setting must contain the complete path to php.exe (or php-win.exe if you do not want a console). For example, C:\WinBinder\PHP\PHP4\php.exe.
  3. You must also include the script name as a parameter. It is the $FileName variable in TextPad and %File% in PSPad. Consult the editor documentation if you have a different editor. Also be sure to include the file path ($Filedir and %Dir% respectively).
  4. Now assign a keyboard shortcut to the newly created tool. PSPad assigns Ctrl+F9 automatically, but you may change the shortcut to your liking in Settings / Program Settings / Key Map / File / Compile. In TextPad, go to Preferences / Keyboard / Tools category, click the command you have just created, then enter the key combination you want in the shortcut edit field. Now you can run a PHP script simply by pressing the shortcut.

Syntax highlighting

To syntax highlight the PHP files and include the WinBinder function names and other keywords:

  1. In TextPad, copy the file tools\textpad\php_winbinder.syn from the WinBinder installation directory to C:\Program Files\TextPad\Samples. In PSPad, copy the file tools\pspad\winbinder.ini from the WinBinder installation directory to C:\Program Files\PSPad\Syntax.
  2. In TextPad, go to Configure / Preferences / Document Classes / PHP, add the .phpw extension to the list, select Syntax in the tree view and set the syntax definition file to php_winbinder.syn. In PSPad, go to Settings / Highlighters Settings, add a new User Highlighter called WinBinder and assign the .phpw extension to it. In PSPad, go to Settings / Highlighters Settings, add a new User Highlighter called WinBinder and assign the .phpw extension to it.

Showing help for PHP and WinBinder words from within your text editor

You may also want to show help for PHP and WinBinder keywords and other reserved words directly from within your text editor.

  1. In PSPad, go to Settings / Highlighters Settings / PHP and type the full path to the PHP manual (e.g. C:\PHP\php_manual_en.chm). The hotkey Alt+F1 will call the PHP help. In TextPad, go to Configure / Preferences / Tools / and add a new Online Help File for php_manual_en.chm.
  2. To add support for WinBinder keywords in PSPad, configure an external application in the Project Settings dialog: hh C:\WinBinder\docs\winbinder.chm::manual/functions/%Word%.html. Now you can position the text cursor over a WinBinder function and press F9 for instant help. In TextPad, go to Configure / Preferences / Tools / and add a new Online Help File to winbinder.chm.

Creating executables

Please go to the WinBinder Forum for information on how to transform a WinBinder program into an executable (.exe).

See also

Creating WinBinder applications