Update 2006-11-01 by FGM: the up-to-date official manual describing the install procedure is located on the main site / docs section.
by Gregory L. Magnusson (c) December 10, 2004 Released under the MIT Software License
PHP, an increasingly popular Web scripting language, is particularly well suited for the creation of dynamic database-connected Web sites. The two strengths that make PHP a powerful server-side scripting language are its abilities to:
- embed directly into existing HTML
- connect to a wide variety of databases
Now, PHP has begun to carve a space for itself in the standalone application arena as well with PHP-GTK. As its name indicates, PHP-GTK combines PHP with the GIMP Tool Kit (GTK), an object-oriented framework for developing graphical user interfaces (GUIs). GIMP (GNU Image Manipulation Program), which was developed using X11 on Linux platforms, basically enables the same PHP-GTK code to run on Linux, MS Windows, BeOS, and Mac 0SX without any changes. So while PHP requires a server (often Apache) to run, you can use PHP-GTK to create standalone GUIs that run on Windows, Linux, or Mac desktops, independently of a server.
This article provides a guide to getting PHP-GTK up and running on your Windows and/or Linux desktop(s), and concludes with a tutorial for building and connecting a simple widgets, buttons, and function in a desktop application.
Deploy PHP-GTK on Windows
First, you have to get a hold of the PHP-GTK installer. Create a folder on your C:\ drive called php_gtk, and download the file:
php-gtk-1.0.0 Windows and PHP Binary including ComboButton, Extra, libGlade, Scintilla, Spaned, SQPane - 23-Oct-2003
You can get a copy of the php-gtk installer from
Then, I suggest downloading the manual, you will
need it soon. Create a folder on your
the documentation there.
Double click the downloaded file to start your file decompression program (e.g., Winzip or Freezip), and extract its files into the C:\php_gtk folder. Navigate to the extracted files in your C:\php_gtk folder. Cut and paste the folder "test" into the folder "php4". If this is a virgin PHP install for you, cut and paste the folder "php4" to your C:\ drive to create C:\php4. If you have PHP installed on your Windows server, keep your php.ini file inside the php4 folder to avoid conflicts (alternatively, you can upgrade your existing php.ini file with the new php-gtk.ini file).
If you run Windows 95/98/XP, copy the php.ini file (found in C:\php_gtk\winnt) to the C:\windows directory. If you run Windows 2000 or Windows NT, copy this php.ini file to your existing C:\winnt folder.
Finally, you have to get the PHP files to associate with php_win.exe. Navigate to C:\php4\test\hello.php and right click on it. Select Open With -> Choose Program:
, and then associate php_win.exe with your .php files by browsing to C:\php4\php_win.exe, selecting Open, and checking the Always use this program to open these files box.
Now, .php extensions will automatically run when they are double clicked, and the desktop icons of existing .php files have changed to the PHP-GTK icon. Navigate to the folder C:\php4\test and double click on hello.php. Try them all to see some of the possibilities of PHP-GTK. One problem Dreamweaver users may face is that Dreamweaver will associate itself with their .php files. To solve this dilemma, open Windows Explorer—>Tools—>Folder Options. For Windows 98 users, this will be Windows Explorer—>View—>Folder Options:
Finally, choose File Types and scroll until you find php and php3:
Click on the Advanced tab and remove any associations. Then click Okay. Navigate to the C:\php4\test folder and check out the sample applications included.
In summary then, you should have the following structure on your C:\ drive
For Windows 98/NT/2000:
In your PHP directory (e.g., c:\php4):
In your Windows directory (e.g., c:\winnt or c:\windows):
In your System32 directory (e.g., c:\winnt\system32 or c:\windows\system32):
Now you should have php-gtk running on Windows. Get into your C:\php_gtkmanual and extract the manual. This manual is continually improving and is your best source for php-gtk tutorials. The manual can also be found online here: PHP-GTK Manual Download. Good luck and good coding.
Linux CVS Install
I find the CVS Version of PHP-GTK to be the most straightforward for a Linux install. The following steps will guarantee you have the most up-to-date version of PHP-GTK. Log into the PHP anonymous CVS server by opening a terminal window. TYPE:
cvs -d :pserver:email@example.com:/repository login
TYPE: phpfi at the password prompt and get the PHP-GTK tree.
TYPE: cvs -d :pserver:firstname.lastname@example.org:/repository co -r PHP_GTK_1 php-gtk
Move into the PHP-GTK directory source tree.
TYPE: cd php
TYPE: cd php-gtk
Configure and install PHP-GTK in typical Linux fashion.
Note: Configure has a lot of options. For a more complicated build, try typing ./configure—help first
TYPE: make install
This should have you up to speed with the most current version of PHP-GTK. Check out the examples supplied with the base install. This is an entirely new world of possibilities for the PHP language. The best place to start is the official PHP-GTK Manual Download.
May the angel of good coding (and good documenation) shine upon you.
Copyright © December 10, 2004
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.