Installing PHPGTK

   

Before you can start using PHPGTK, you need to download the appropriate files. The PHPGTK team has set up a nice Web site at http://gtk.php.net. The PHPGTK Web site has downloads and documentation for the GTK extension.

Before You Install

PHPGTK still has not reached the 1.0 version, and as such I wouldn't recommend that you use this version of PHP on your production Web server. In fact, there really isn't a reason that you'd want to install PHPGTK on your production Web server. It is a client-side application!

PHPGTK is a developers' toy at the moment, and anything is subject to change, at least before PHPGTK reaches version 1.0. Have some fun with it, try it out, but don't base your company's next big product on PHPGTK 0.5.0.

Installing on Windows

Installing PHPGTK on a Windows machine is fairly straightforward and similar to installing the normal version of PHP. Download the Windows binary file from the PHPGTK Web site at http://gtk.php.net.

Unzip the file using a zip utility such as WinZip. Extract the files to your C: drive.

The following folders are created when you unzip the file:

  • php4 Contains the PHP executable, as well as some GTK library files.

  • test Contains some sample *.php files that use the GTK widget set.

If you are using Windows 98 or Windows ME, then you will notice that folders called "winnt" and "winnt/system32" have been created. You should copy the contents of those folders into your C:\windows directory. Note that you may have to set your system files to be viewable so that you can see the necessary DLL files to copy them over to C:\windows.

Additionally, you should see a new php.ini file. Copy this to your C:\Windows or C:\WINNT directory. Be sure to first back up your existing php.ini file.

To test out the installation, type the following from a command prompt:

 c:\php4\php.exe -q c:\test\gtk.php  

See Figure 12-1 for a screen shot of the gtk.php file in action.

Figure 12-1. gtk.php in Linux (Gnome) and Windows 2000

graphics/12fig01.jpg

Installing on Linux

Installing PHPGTK on Linux is easier than installing the normal PHP; you don't have to worry about compiling with Apache. You can compile GTK functionality into an existing standalone version of PHP, but for our purposes we'll start from scratch and make a brand new PHP executable that has GTK functionality built in. Before you begin:

  1. Download the source file for PHP from the download page at www.php.net.

  2. Download the source file PHPGTK from the download page of http://gtk.php.net.

Once you have the necessary file, unzip and untar the regular PHP source file:

 tar -zxvf php-4.x.x.tar.gz  

This creates a new directory named php-4.x.x, where the "x" denotes the exact version number of PHP that you downloaded.

Compile PHP using the minimum options. We just want to create a standalone executable. If you want to add additional functionality, you can recompile later. For now, you just want to make sure you can create a working version of PHPGTK. Change directory into your newly created PHP source directory. Compile by typing:

 ./configure  

That's all there is to it. This automatically creates an executable that has built-in MySQL support as well.

Once you have the php binary file, you must copy it to /usr/local/bin. The PHPGTK installation will be looking for it in that location. You need to be root to do this.

 cp php /usr/local/bin  

Now, it's time to build the GTK extension onto your PHP executable. Go back to where you downloaded the PHPGTK source file and extract it:

 tar -zxvf php-gtk-0.5.0.tar.gz  

This creates a new directory named php-gtk-0.5.0. Change directory into that directory and compile the source file. You will need to be root to perform the final step, make install. To compile PHPGTK, type the following (a lot of text will print to the screen after you type each command):

  1. ./compile

  2. make

  3. make install

You can test your installation by going into the test directory and running a few of the scripts. X-Windows will need to be running!

 cd test  php -q gtk.php 

A window should pop up showing various GTK widget buttons. Click the different widgets to get a brief idea of what they do.

Figure 12-1 shows the gtk.php file as it appears in Linux (using the Gnome desktop) on the left and in Windows 2000 on the right.

You can also try running the other *.php files in the test directory. Use the -q flag to suppress printing HTTP header information to the screen (the php "quiet" option).


   
Top


Advanced PHP for Web Professionals
Advanced PHP for Web Professionals
ISBN: 0130085391
EAN: 2147483647
Year: 2005
Pages: 92

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net