Installation tutorials

This is a list of various articles that reference the PHP-GTK installation process on various OS platforms, using either the canonical distribution from gtk.php.net or alternate distributions like Gnope.

A Basic Tutorial for Installation of the PHP-GTK Language Runtime v.1

Update 2006-11-01 by FGM: the up-to-date official manual describing the install procedure is located on the main site / docs section.


by Gregory L. Magnusson (c) December 10, 2004 Released under the MIT Software License

PHP, an increasingly popular Web scripting language, is particularly well suited for the creation of dynamic database-connected Web sites. The two strengths that make PHP a powerful server-side scripting language are its abilities to:

  • embed directly into existing HTML
  • connect to a wide variety of databases

Now, PHP has begun to carve a space for itself in the standalone application arena as well with PHP-GTK. As its name indicates, PHP-GTK combines PHP with the GIMP Tool Kit (GTK), an object-oriented framework for developing graphical user interfaces (GUIs). GIMP (GNU Image Manipulation Program), which was developed using X11 on Linux platforms, basically enables the same PHP-GTK code to run on Linux, MS Windows, BeOS, and Mac 0SX without any changes. So while PHP requires a server (often Apache) to run, you can use PHP-GTK to create standalone GUIs that run on Windows, Linux, or Mac desktops, independently of a server.

This article provides a guide to getting PHP-GTK up and running on your Windows and/or Linux desktop(s), and concludes with a tutorial for building and connecting a simple widgets, buttons, and function in a desktop application.

Deploy PHP-GTK on Windows

First, you have to get a hold of the PHP-GTK installer. Create a folder on your C:\ drive called php_gtk, and download the file: php-gtk-1.0.0 Windows and PHP Binary including ComboButton, Extra, libGlade, Scintilla, Spaned, SQPane - 23-Oct-2003

You can get a copy of the php-gtk installer from php-gtk headquarters

Then, I suggest downloading the manual, you will need it soon. Create a folder on your C:\ drive called php_gtkmanual and download the documentation there.

Double click the downloaded file to start your file decompression program (e.g., Winzip or Freezip), and extract its files into the C:\php_gtk folder. Navigate to the extracted files in your C:\php_gtk folder. Cut and paste the folder "test" into the folder "php4". If this is a virgin PHP install for you, cut and paste the folder "php4" to your C:\ drive to create C:\php4. If you have PHP installed on your Windows server, keep your php.ini file inside the php4 folder to avoid conflicts (alternatively, you can upgrade your existing php.ini file with the new php-gtk.ini file).

If you run Windows 95/98/XP, copy the php.ini file (found in C:\php_gtk\winnt) to the C:\windows directory. If you run Windows 2000 or Windows NT, copy this php.ini file to your existing C:\winnt folder.

Finally, you have to get the PHP files to associate with php_win.exe. Navigate to C:\php4\test\hello.php and right click on it. Select Open With -> Choose Program:

—>Other

, and then associate php_win.exe with your .php files by browsing to C:\php4\php_win.exe, selecting Open, and checking the Always use this program to open these files box.

Now, .php extensions will automatically run when they are double clicked, and the desktop icons of existing .php files have changed to the PHP-GTK icon. Navigate to the folder C:\php4\test and double click on hello.php. Try them all to see some of the possibilities of PHP-GTK. One problem Dreamweaver users may face is that Dreamweaver will associate itself with their .php files. To solve this dilemma, open Windows Explorer—>Tools—>Folder Options. For Windows 98 users, this will be Windows Explorer—>View—>Folder Options:

Finally, choose File Types and scroll until you find php and php3:

Click on the Advanced tab and remove any associations. Then click Okay. Navigate to the C:\php4\test folder and check out the sample applications included.

In summary then, you should have the following structure on your C:\ drive

For Windows 98/NT/2000:

In your PHP directory (e.g., c:\php4):

php.exe 
php4ts.dll 
php_gtk.dll

In your Windows directory (e.g., c:\winnt or c:\windows):

php.ini 

In your System32 directory (e.g., c:\winnt\system32 or c:\windows\system32):

gtk-1.3.dll 
gdk-1.3.dll 
gmodule-1.3.dll 
glib-1.3.dll 
iconv-1.3.dll 
gnu-intl.dll 

Now you should have php-gtk running on Windows. Get into your C:\php_gtkmanual and extract the manual. This manual is continually improving and is your best source for php-gtk tutorials. The manual can also be found online here: PHP-GTK Manual Download. Good luck and good coding.

Linux CVS Install

I find the CVS Version of PHP-GTK to be the most straightforward for a Linux install. The following steps will guarantee you have the most up-to-date version of PHP-GTK. Log into the PHP anonymous CVS server by opening a terminal window. TYPE: cvs -d :pserver:cvsread@cvs.php.net:/repository login

TYPE: phpfi at the password prompt and get the PHP-GTK tree.

TYPE: cvs -d :pserver:cvsread@cvs.php.net:/repository co -r PHP_GTK_1 php-gtk

Move into the PHP-GTK directory source tree.

TYPE: cd php
TYPE: cd php-gtk 

Configure and install PHP-GTK in typical Linux fashion.

TYPE: ./buildconf 
TYPE: ./configure 

Note: Configure has a lot of options. For a more complicated build, try typing ./configure—help first

TYPE: make
TYPE: make install 

This should have you up to speed with the most current version of PHP-GTK. Check out the examples supplied with the base install. This is an entirely new world of possibilities for the PHP language. The best place to start is the official PHP-GTK Manual Download.

May the angel of good coding (and good documenation) shine upon you.

Copyright © December 10, 2004

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Compile That PHP-GTK2, and More

One thing that causes a lot of problems still right now is the lack of pre-compiled packages for Linux distributions. Between that and users who would just want to compile their own anyway I get a lot of questions about how to setup a system for, and compile, PHP-GTK2. Personally, I get a bit weary of repeating the same instructions over and over, so I have turned out a work-in-progress guide to compiling PHP-GTK2 on Unix systems with notes aimed to help people on certain distributions.

How To Compile - With Special Notes For:

  • Ubuntu 7.10 (Gutsy)
  • FreeBSD
  • Solaris 10

Also up on my site I have begun formatting some of my PHP-GTK2 Object Oriented tutorials for the web. I hope that these documents can help you get started and harness the full power of PHP-GTK.

Visit My Site for all sorts of tutorials or jump straight to the guide to compiling PHP-GTK2.

Install PHP-GTK 2 on MS-Windows™ - PiGii

Licenses

First of all, be prepared to accept the terms of the agreement for the following licenses:

Choices

Still here? Well, now you are ready to choose the pack you need: lite, standard, or huge. Here are 3 criteria to help you choose:
Criteria                        Lite    Standard    Huge
What other users have chosen    15 %      20 %       65 %
The sizes of each pack         5.1 MB    7.9 MB    12.4 MB
For the detailed report of features, see the pigii website.

That Simple

  • Once downloaded, run the selected pack and Agree with the licenses or Cancel... you were warned.
  • If you did agree with the licences, then fine tune your selection of the included components or packages. A short description is displayed in front of each component when the mouse is positionned over its name. The components are organized as tree. Entire branches of that tree are selected and deselected very easily by checking or unchecking a box.
  • Once the boxes are checked, enter the destination folder. Here, PiGii has already set an entry which is either based on %ProgramFiles% or based on the previous install.
PiGii is that simple.

The MS-Windows™ Registry

In order to be able to uninstall a version or to install a newer version, PiGii needs to store some informations inside that registry. The name of the main registry key is:
  • HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\PHP-GTK
  • From version .009 (07-jan-2010), PiGii also writes information for other programs. The name of the registry keys are:
    • HKLM\Software\PHP\
    • HKLM\Software\GTK\2.0\

What else?

Install PHP-GTK 2 on MacOS X

Installation of PHP-GTK 2 on MacOS X 10.4 and 10.5 is actually pretty simple, as it can use the latest PHP-GTK installer, which works just like any other Mac installer.

Just follow the screenshots below this text. The installer includes all the pre-requisites required for PHP to run , but the best feature of the installer is that you don't need X to run GTK+ apps, and the theme is by default Quartz-engine powered, which means you get the whole native Mac look.

For those interested in technical details, a complete list of the prerequisites is given at step 2 of the installation. Download the installer at http://www.kix.in/php-gtk2/PHP-GTK-2.0.0.dmg

Well, I guess that's about what's there to say!

Cheers,

Anant,

Installing PHP-GTK 2 on MacOS X, step 1
Installing PHP-GTK 2 on MacOS X, step 2
Installing PHP-GTK 2 on MacOS X, step 3
Installing PHP-GTK 2 on MacOS X, step 4
Installing PHP-GTK 2 on MacOS X, step 5

Install PHP-GTK 2 with Gnope for UNIX-Linux

About Gnope

Gnope is a central site where you can find interesting applications and library for PHP-GTK developpement. Gnope has a repository for quick access to package installation. Gnope package managment is based on pear, so you need to have a working pear environment to start working with Gnope. If you have built PHP-GTK on your own, you should have pear installed. You just have to locate the pear command :

locate '*bin/pear*'

Installation steps

You should have a look a basic options of the pear command :

  pear help
  pear config-show
  pear install
  

If you are behind a firewall with a proxy for internet connection, just configure pear to use the proxy:

  pear config-set http_proxy http://hostname:port/
  

Many packages in pear are available in an early developpement status. You have to choose a level state for package developpement. If you choose a low level, you can access many packages. If you choose a high stability level, a smaller number of packages will be available for installation.

  # possible values : stable beta alpha devel snapshot ; default : stable
  pear config-set preferred_state devel
  

Now we have to discover Gnope channel :

  pear channel-discover gnope.org
  

Now install 2 mandatory packages ; after that, you will be able to drive Gnope application graphically :

  pear install --alldeps PEAR_Frontend_Gtk2
  pear install --alldeps gnope/Gnope_AppRunner
  pear install PEAR_Frontend_Gtk2
  

At this point, Gnope "runner" and "installer" should be installed.

Ubuntu linux

You need to install first some packages before using pear command :

  sudo apt-get install php5-cli php-pear

Also, you'll need to build php-gtk2 extention ; there is a tutorial page in this wiki

Running

Applications should be located in PEAR_DIR/lib/php/..... To provide an easy acces to those applications, here is a nice bash script named gnope :

#!/bin/sh

# gnope command line interface to package :
# - Gnope_AppRunner : 
# - Pear Gtk2 frontend installer
#
# links : 
#  http://www.gnope.org/
#  http://pear.php.net/
#

pear_dir=`pear config-show | grep php_dir | sed -e 's/PEAR.*php_dir//' -e 's/\s*//'`

case "$1" in
  runner)
    exec php -q $pear_dir/Gnope/AppRunner/run.phpw
    ;;

  installer)
    exec php -q $pear_dir/PEAR/Frontend/Gtk2/run.phpw
    ;;

  *)
    echo $"Usage: $0 {runner|installer}"
    ;;
esac

Script usage :

  • gnope runner : will run application selection and runner interface,
  • gnope installer : will launch pear (gnope) application installer user interface.

Links

PHP-GTK installer for windows

A PHP-GTK installer for Windows, it includes PHP-GTK (PHP 5.3.4 + php-gtk snap + cairo),PHP Extensions, Some Gtk Locales, File Associations and demo scripts

Fixed incompatibility between extensions and core due to version mismatch

screenshot for PHP-GTK installer

You can install only PHP-GTK core files, the full install or choose what to install. Made with Inno Setup, questions, suggestions and feature requests are welcome

I've included the CairoForPhp Samples application (published here) by Florian Freeman, hope he doesn't mind