One of the better inventions of the 21st Century is with no doubt PHP-Gtk. Released in March 2001, in an effort to show that PHP isn't just a web scripting language, PHP-Gtk offers coders running GTK the opportunity to create custom desktop applications without having to meddle outside of their language of choice.
In this article, I'm going to walk you through the process of installing PHP-Gtk on a Linux desktop. I'm running KRUD 8, from, using Gnome, but everything here should work with any distro.
As a side note, PHP-Gtk is also available to Windows users. Unfortunately, I rarely delve into the world of Windows, so I won't attempt to overlap. It'd be great if someone could chime in with another article centering on the Windows install. Until, then I'd recommend posting in our PHP Install forum, searching the PHP-Gtk archive or posting on the general mailing list if you run into a snag. The last two can be found here:
What You'll Need
As you probably guessed, you will need a Linux desktop running Gtk. The developers are currently planning to implement a Gtk2 version, but as of this writing, it's not yet available and there is no solid target date. No worries though if you're running Gtk2, the Gtk functionality should still work fine.
You'll also need the latest version of PHP and PHP-Gtk. "make" and a C compiler will also be needed in order to compile the source. Both of these are standard includes with most Linux distros and can be easily installed using your normal package manager.
Installing the PHP binary
Once you have the source on your drive and decompressed, you'll need to run the PHP configure script. To keep things simple, this first time around, I'll use a very basic config. cd into your PHP source directory and run:
./configure --with-mysql --with-gettext
and then:
make install
And you should be all set to run PHP via command line.
Installing PHP-Gtk
Once you have PHP installed, it's time to move on to PHP-Gtk. This is the part that can sometimes be a bit tricky. If you run into a roadblock, I recommend just starting over and be sure to include all the steps. I once spent hours trying to track down an issue and it turned out that I had forgotten to run buildconf beforehand. Provided all the planets are aligned, the install should be very simple if you follow all the steps below.
cd into your PHP-Gtk directory and run:
If you see feedback saying you should run aclocal then, you guessed it, run aclocal:
and finally:
make install
This should take care of the basic PHP-Gtk functionality and the normal PHP functions.
Checking your work
Since this is intended as a precursor to a series of PHP-Gtk articles, I'll simply provide a quick cut and paste script, to make sure everything is as nature intended.
Copy the following code into a file, in your home directory, named simple.php:

#!/usr/local/bin/php -q 


function quitApplication()

dl'' ) || die( 'Unable to load php_gtk module! YOU BROKE ME!\n' );

$window = &new GtkWindow;
$window->set_title("PHP does GTK");

$window->connect'delete_event''quitApplication' );


You may need to change the path to your PHP binary in the first line. This can be found by typing 'which php' at the command prompt. Once that's done, at the prompt type:
This should open a blank window. If so, you're ready to move on. If not, back up and try again. As always, if you run into a snag, you can find some help in our community forums.
In the next article we'll deal with creating a more likable interface using Glade. Until then...
I'd like to thank Steph Fox from the PHP-Gtk team for her help with clarifying some of the info contained in this article and the ones to follow. Everyone say "HI STEPH!!" :)