The best way to install PHP-GTK 2 on Linux is to compile it. No binary or source packages are available as yet for any distribution, so you can't use your favorite package manager to install PHP-GTK 2! These instructions should be valid for most distributions of Linux, as well as other POSIX compliant systems.
There are two ways to go about installing PHP-GTK 2 on your Linux system. You can either choose to use your existing PHP installation, or decide to install a separate one and dedicate it to PHP-GTK 2. The latter is a simpler method and is recommended for users with little or no Linux experience. In any case, you need Gtk+ version 2.6 upwards installed.
Just follow these steps, and you should be okay! First thing you need is a fresh checkout of PHP. You can choose either the 5_1 or 5_2 branches, both work fine:
$ cvs -d :pserver:email@example.com:/repository login $ cvs -d :pserver:firstname.lastname@example.org:/repository co -r PHP_5_2 php-src
$ cd php-src $ ./buildconf $ ./configure --prefix=/opt/php5_2 --disable-cgi $ make $ su $ make install $ echo extension=php_gtk2.so >> /opt/php5_2/lib/php.ini $ /opt/php5_2/bin/php-config --extension-dir | xargs echo 'extension_dir=' >> /opt/php5_2/lib/php.ini
Now, let's checkout and install PHP-GTK 2:
$ cd .. $ cvs -d :pserver:email@example.com:/repository co php-gtk $ cd php-gtk $ ./buildconf --with-phpize=/opt/php5_2/bin/phpize $ ./configure --with-php-config=/opt/php5_2/bin/php-config $ make $ make install
You might want to create a link to the new php executable:
$ ln -s /opt/php5_2/bin/php /usr/bin/php-gtk
If you decide to 'add-on' PHP-GTK 2 to your existing PHP installation, ensure that your version of PHP is at least 5.1 with CLI enabled. PHP-GTK 2 will NOT work with any other versions of PHP. You can check your PHP version by typing php -v on the command line. Don't forget to check if the word cli appears in the output!
Now, checkout the latest CVS source of PHP-GTK 2, or download the Alpha source tarball, as per instructions on the PHP-GTK 2 download page. cd into the checked out / extracted directory, and execute the following:
$ ./buildconf $ ./configure $ make $ make install
This should just work for most people. However, if there are multiple installations of PHP in your machine or you have installed PHP in some exotic location, you might face trouble. Most of these cases can be solved by specifying the exact locations of the phpize and php-config files:
$ ./buildconf --with-phpize=/path/to/phpize $ ./configure --with-php-config=/path/to/php-config
Before you can use PHP-GTK 2, you need to enable the extension in your php.ini. Just add a
You can test whether your installation was successful by executing:
$ php -m | grep php-gtk
Next, you can try out the demo applications in the demos directory of the php-gtk sources, e.g. demos/phpgtk2-demo.php.