Subentry of PHP-GTK

Compiling PHP-GTK on UNIXesque OS

Tue29May2007

Contents
Before You Begin

This document does not care about what distribution you use, these instructions will work on all shapes of Linux. It is up to you to translate any line into the required line for your distribution, for example if you choose to use the package manager as much as possible instead of installing all the dependencies manually. I will however tell you right now, if you are on Ubuntu and never done this before, you are missing pretty much every package you need.

This document also assumes you are NOT running Apache on your computer. Why? Because you do not need Apache to use PHP-GTK. In fact if you have PHP-GTK loading in Apache, Apache will cry then die.

 


Requirements

To compile PHP-GTK you need several things:
      1. Autotools (automake, autoconf, etc...)
      2. Compile Tools (make, gcc, etc...)
      3. GTK+ 2.10 or newer, including headers.
      4. PHP 5.2 or newer, including headers.
      5. LibGlade, including headers.
      6. CVS.

ANY self-respecting distribution will already have your Autotools and the Compile Tools already installed and setup right off the Installation CD, so chances are you can ignore #1 and #2. Installing these is far beyond the scope of this document but they can usually be done with your distribution package manager if they are not installed making your life easy.

ANY modern distribution will have GTK+ 2.10 or newer installed, if you are using Gnome, XFCE, or any GTK applications then you have it. However you might not have the headers, and by that I mean development packages. You must have the development packages installed. If you compiled and installed GTK from source then you are done. If not scan your package manager, also install any Pango or ATK development packages if you see them.

PHP 5.2 or newer. If your package manager will allow you to install this without installing Apache, then you are in fact a winner. Distributions that overmodularize will probably require you to install several packages such as `php5`, `php5-gd`, and `php5-cli`. Install those at least, and also the development package, probably named something like `php5-dev`. Personally I would suggest compiling your own PHP unless you are using a distribution like KateOS which already has PHP-GTK installed for you. Of course if you were using KateOS, why would you be reading this?

Too many PHP-GTK applications depend on LibGlade, so you should install it because chances are you will eventually run into a program using it.

Install CVS if you do not have it already, because that is how we are going to get the PHP-GTK source. The CVS repository usually has fixes that are not yet out. One such is a problem with if your package had a separate package for PHP-GD like I said above. There is a fix for this in PHP-GTK which was added after the most recent release, I will update this document the next PHP-GTK release to reflect that change and hereby eliminiating this step.

 


Getting PHP-GTK

You need the source to compile it, so run these CVS commands:

cvs -d :pserver:cvsread@cvs.php.net:/repository login
<hit enter when it asks for a password>
cvs -d :pserver:cvsread@cvs.php.net:/repository co php-gtk

 

It will do it's thing, and after you have a new php-gtk directory. Change into that new directory.

 

Compiling PHP-GTK

Run the command:

./buildconf

 

If this does not complete successfully then you are probably missing packages. A common error is 'unable to find phpize' and this means you did not install the PHP development package.

After Buildconf, run the command:

./configure

 

The same rules apply here, if it fails to complete successfully you probably forgot to install some packages or their development counterpart packages. Scroll back up through the output to make sure it found LibGlade. You can still use PHP-GTK without this but when you download a program and it says 'unknown class: GladeXML' that is because you did not listen to me when I said to install LibGlade.

So Configure finally completed successfully? Next, run the command:

make

 

Wait for it... wait for it... did it complete successfully? It really should have, by now you should have fixed all the dependency problems. When that finishes (successfully) then you can run the command (as root):

make install

 

When that finishes, PHP-GTK is now installed. But hang on, you are not done yet.

 


Configure PHP and PHP-GTK

Short description of this section: load the PHP-GTK module in PHP.INI.

You need to edit your PHP.INI file. If you do not know where it is at, run this command:

//. bob@elenothar [/]$ php -i | grep Loaded
Loaded Configuration File => /etc/gtk/php.ini

 

See? It told me I need to edit the /etc/gtk/php.ini. Open the file it told you in your favourite text editor, you might need to be root. Scroll down to the end of this file and add the following lines:

extension = "php_gtk2.so"
[php-gtk]
php-gtk.codepage = "UTF-8"
php-gtk.extensions = ""

 

All four of those lines were important. Once you add that to your PHP.INI to test if GTK is being loaded, run this command:

//. bob@elenothar [/]$ php -i | grep GTK
GTK+ support => enabled
GTK+ v => 2.10.14

 

This means everything is good to go. If it did not tell you GTK+ support is enabled then check that the `make install` completed successfully.

If you have any questions feel free to ask me, you can find me on IRC: irc.freenode.net #php-gtk.