This is an update to a document I wrote 4 years ago about compiling PHP-GTK on any Unixesque system you could get your hands on, but this one only for Ubuntu 10+. At the time of writing I was using a freshly installed Ubuntu 10.10 system to do this, so for the sake of completeness we are going to assume the system has nothing we need as though it was fresh off the installation disk a few minutes ago.
Here is an overview of what we have to do. The order is very important. If you do not follow the proper order things will not work right. This becomes very important when it comes time to build PHP-GTK itself.
- Install subversion.
- Install PHP5.
- Install GTK development packages.
- Install the Cairo module for PHP.
- Get, patch, and compile PHP-GTK.
And here is how we do it. You are going to need a terminal window.
Install Subversion.
We need to install subversion because we are going to download the freshest copies of Cairo and PHP-GTK2. Subversion is in our package repository, so all we have to do is:
Command Line Interface (CLI):$ sudo apt-get install subversion
Install PHP5 and GTK development packages.
Everything PHP-GTK depends on (which the exception of Cairo) is in our package repository.
Command Line Interface (CLI):$ sudo apt-get install php5-cli php5-dev libgtk2.0-dev
This command should inform you that in order to install these three packages, you need to install about 50 others. Accept the dependencies, sit back, relax, and let it all install.
Install the Cairo module for PHP.
Next we need to build the Cairo module for PHP as PHP-GTK depends on it. Grab the latest source for Cairo using subversion.
Command Line Interface (CLI):co http://svn.php.net/repository/pecl/cairo/trunk cairo
Now we build it. Move into the Cairo directory and compile it.
Command Line Interface (CLI):$ phpize
Command Line Interface (CLI):$ ./configure
Command Line Interface (CLI):$ make
Command Line Interface (CLI):$ sudo make install
Now we need to load it in PHP. Edit the file /etc/php5/cli/php.ini in your favourite editor (with root permissions), zip down to the end and add the line:
extension=cairo.so
Save and confirm that it worked by checking that cairo is listed in PHP with the command:
Command Line Interface (CLI):$ php -m
Get PHP-GTK.
Using subversion again we will download the latest PHP-GTK.
Command Line Interface (CLI):co http://svn.php.net/repository/gtk/php-gtk/trunk php-gtk
Patch PHP-GTK.
We need to patch the PHP-GTK source because Ubuntu is using a version of libtool which appears to be different than what other distributions are using. If you try and compile PHP-GTK without patching it you will see errors similar to these:
configure.in:77: warning: LTOPTIONS_VERSION is m4_require’d but not m4_defun’d
aclocal.m4:2912: LT_INIT is expanded from…
aclocal.m4:2947: AC_PROG_LIBTOOL is expanded from…
configure.in:77: the top level
configure.in:77: warning: LTSUGAR_VERSION is m4_require’d but not m4_defun’d
configure.in:77: warning: LTVERSION_VERSION is m4_require’d but not m4_defun’d
configure.in:77: warning: LTOBSOLETE_VERSION is m4_require’d but not
configure.in:51: error: possibly undefined macro: AC_MSG_ERROR
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure:4266: error: possibly undefined macro: AM_PATH_GLIB_2_0
configure:4397: error: possibly undefined macro: AM_PATH_GTK_2_0
./configure: line 4242: syntax error near unexpected token `debug,’
./configure: line 4242: `PHP_GTK_ARG_ENABLE(debug, whether to include debugging symbols,’
Which long story short, are no good. The good news is the patch is really tiny and I have it for you to download right here. Go back to your terminal and move into the PHP-GTK source we downloaded from the subversion.
Command Line Interface (CLI):$ wget http://squirrelshaterobots.com/files/phpgtk/phpgtk-buildfix-20090105a.diff
Command Line Interface (CLI):$ patch -p1 < phpgtk-buildfix-20090105a.diff
patching file build2/build2.mk
Hunk #1 succeeded at 10 with fuzz 2.
You MUST do this patch before executing any of the compile scripts in PHP-GTK, or else the autotools chain will make cache files that render the patch file ineffective.
Compile PHP-GTK.
At this point we should be ready to compile PHP-GTK.
Command Line Interface (CLI):$ ./buildconf
Command Line Interface (CLI):$ ./configure
Command Line Interface (CLI):$ make
Command Line Interface (CLI):$ sudo make install
Once the compiling is done, edit theĀ /etc/php5/cli/php.ini again in your favourite editor (with root permissions), and add this line underneath the one you added earlier:
extension=php_gtk2.so
Verify that PHP-GTK2 is being loaded by checking the module list again.
Command Line Interface (CLI):$ php -m
You should now see both cairo and php-gtk in the PHP module list. That means you are good to go.
Last minute notes.
Right now we have Cairo and PHP-GTK being loaded by Ubuntu’s default CLI php.ini file. This means every time PHP is run from the command line PHP-GTK will be loaded. This will not work very well if we are using PHP from something like a recovery console or over SSH. To get around this we create a new PHP.INI just for PHP-GTK applications, which I will cover in another post over the weekend.

sudo add-apt-repository ppa:omidmottaghi/php-gtk
sudo apt-get update
sudo apt-get install php5-gtk2
sudo apt-get install php5-dbus
Post #2
http://ubuntuforums.org/showthread.php?t=1377395
I install php-gtk but i don't have support for sourceview gtkhtml mozilla-embed
Could you tell me how to install it on ubuntu support sourceview 11.10
I have installed sourceview2.0 2.0-dev and 3.0 3.0-dev but not detected
./configure --with-extra --with-html --with-libsexy --with-spell --enable-php-gtk --with-mozembed --with-sourceview
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for a sed that does not truncate output... /bin/sed
checking for cc... cc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether cc accepts -g... yes
checking for cc option to accept ISO C89... none needed
checking how to run the C preprocessor... cc -E
checking for icc... no
checking for suncc... no
checking whether cc understands -c and -o together... yes
checking for system library directory... lib
checking if compiler supports -R... no
checking if compiler supports -Wl,-rpath,... yes
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for PHP prefix... /usr
checking for PHP includes... -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php5/ext/date/lib -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
checking for PHP extension directory... /usr/lib/php5/20090626+lfs
checking for PHP installed headers prefix... /usr/include/php5
checking if debug is enabled... no
checking if zts is enabled... no
checking for re2c... re2c
checking for re2c version... 0.13.5 (ok)
checking for gawk... gawk
checking for PHP-GTK support... yes, shared
checking for PHP executable in /usr/bin... found version 5.3.10-1~dotdeb.1
checking for gawk... (cached) gawk
checking whether to include debugging symbols... no
checking for pkg-config... /usr/bin/pkg-config
checking for GLIB - version >= 2.6.0... yes (version 2.30.0)
checking for pkg-config... (cached) /usr/bin/pkg-config
checking for GTK+ - version >= 2.6.0... yes (version 2.24.6)
checking for atk >= 1.9.0... yes
checking ATK_CFLAGS... -pthread -I/usr/include/atk-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include
checking ATK_LIBS... -pthread -latk-1.0 -lgobject-2.0 -lgthread-2.0 -lrt -lglib-2.0
checking for pango >= 1.8.0... yes
checking PANGO_CFLAGS... -pthread -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include
checking PANGO_LIBS... -pthread -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
checking for gtkextra support... yes
checking for gtkextra-2.0 >= 2.1.1... Unable to locate gtkextra version 2.1.1 or higher: not building
checking for html support... yes
checking for libgtkhtml-3.8 >= 3.10.0... Unable to locate libgtkhtml version 3.10.0 or higher: not building
checking for libglade support... yes
checking for libglade-2.0 >= 2.4.0... yes
checking LIBGLADE_CFLAGS... -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/libglade-2.0 -I/usr/include/libxml2
checking LIBGLADE_LIBS... -pthread -lglade-2.0 -lgtk-x11-2.0 -lxml2 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
checking for libsexy support... yes
checking for libsexy >= 0.1.10... Unable to locate libsexy version 0.1.10 or higher: not building
checking for GtkMozEmbed support... yes
checking for firefox-gtkmozembed >= 1.5.0... checking for mozilla-gtkmozembed >= 1.7.0... Unable to locate firefox-gtkmozembed version 1.5.0 or mozilla-gtkmozembed version 1.7.0 or higher: not building
checking for scintilla support... no
checking for sourceview support... yes
checking for gtksourceview-1.0 >= 1.2.0... Unable to locate sourceview version 1.2.0 or higher: not building
checking for spell support... yes
checking for gtkspell-2.0 >= 2.0.0... yes
checking SPELL_CFLAGS... -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include -I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 -I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gtkspell-2.0
checking SPELL_LIBS... -pthread -lgtkspell -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgio-2.0 -lpangoft2-1.0 -lpangocairo-1.0 -lgdk_pixbuf-2.0 -lcairo -lpango-1.0 -lfreetype -lfontconfig -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lglib-2.0
creating main/php_gtk_ext.c
checking how to print strings... printf
checking for a sed that does not truncate output... (cached) /bin/sed
checking for fgrep... /bin/grep -F
checking for ld used by cc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-linux-gnu file names to i686-pc-linux-gnu format... func_convert_file_noop
checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from cc object... ok
checking for sysroot... no
checking for mt... mt
checking if mt is a manifest tool... no
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if cc supports -fno-rtti -fno-exceptions... no
checking for cc option to produce PIC... -fPIC -DPIC
checking if cc PIC flag -fPIC -DPIC works... yes
checking if cc static flag -static works... yes
checking if cc supports -c -o file.o... yes
checking if cc supports -c -o file.o... (cached) yes
checking whether the cc linker (/usr/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... no
configure: creating ./config.status
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing libtool commands
thanks