First we install prerequisite packages:
sudo apt-get install build-essential subversion php5-cli php5-dev libgtk2.0-dev libglade2-dev
Next we install Cairo library:
cd ~/Downloads
svn co http://svn.php.net/repository/pecl/cairo/trunk pecl-cairo
cd pecl-cairo
phpize
./configure
make
sudo make install
Now to properly compile php-gtk library we have to make following changes:
cd /usr/share/aclocal
sudo cp libtool.m4 libtool.m4.backup
sudo chmod 777 libtool.m4
sudo cat lt~obsolete.m4 ltoptions.m4 ltsugar.m4 ltversion.m4 >>libtool.m4
sudo chmod 644 libtool.m4
Now we download, compile and install php-gtk library:
cd ~/Downloads
svn co http://svn.php.net/repository/gtk/php-gtk/trunk php-gtk
cd php-gtk
./buildconf
./configure
make
sudo make install
The last step is configuring php-cli to point to proper php-gtk extension location. In order to do this we have to divide php-cli and php-apache configuration files:
sudo rm /etc/php5/cli/conf.d
sudo mkdir /etc/php5/cli/conf.d
sudo cp /etc/php5/conf.d/*.ini /etc/php5/cli/conf.d/
Now edit /etc/php5/cli/php.ini file and add following lines in Dynamic Extensions section:
extension=php_gtk2.so
extension=cairo.so
Everything is installed and configured now. Check proper working of php-gtk library
by running example application:
php ~/Downloads/php-gtk/demos/gtkiconview.php