Article

Build Cross-Platform Windowed Apps with PHP

Page: 1 2 3 4 5 6 7 8 Next

Downloading and Installing PHP-GTK

As with all GPL licensed software, PHP-GTK is a completely free download. Visit the GTK site and choose the version of PHP-GTK that matches your operation system. At the time of writing, you could choose to download the source, windows binary, as well as the concurrent versions system (CVS) download.

Installing PHP-GTK for Windows

I'm running Windows 2000 with PHP-GTK, so I'll give you my overview of installing PHP-GTK on Windows. Firstly, make sure you're equipped with an unzip program such as WinZip. Next, locate the directory where PHP is installed. If you installed PHP using the default options it will be c:\php4.

Extract all the files in the downloaded zip file to a directory such as c:\temp. Copy all of the files from the php4 directory to your current PHP extensions directory, which can be found in your php.ini file (typically it's either the directory where you installed PHP, such as c:\php4, or the extensions directory of your PHP installation, such as c:\php4\extensions).

You'll notice a file called php_win.exe. This executable can be used to run PHP-GTK scripts by simply double clicking on them. Before continuing, let's set up Windows so that our PHP-GTK scripts will be run automatically when we double click on them.

Double click on any PHP script on your computer. When the "Open With..." dialog appears, choose other and browse to c:\php4\php_win.exe. Make sure the "Always use this program" checkbox is ticked and click OK. You'll notice that all your PHP files now have the PHP-GTK icon.

Ok, back to the installation. The winnt directory in your PHP-GTK download contains a php.ini file. If you don't have a php.ini file in your windows directory already (which is c:\windows for Windows 95 and 98 and c:\winnt for Windows NT, 2000 and XP), then copy that php.ini file there.

Next, copy all of the files from the winnt\system32 directory of your download to your Windows system directory, which is c:\windows\system for Windows 95 and 98 users and c:\winnt\system32 for Windows NT, 2000 and XP users.

Run sysedit (Start -> Run -> "sysedit") and add the following line to the end of your autoexec.bat file:

path=%path%;c:\php4

Lastly, copy the test directory to the same directory where PHP is installed. The test directory contains a couple of PHP-GTK scripts that demonstrate how to create and interact with the various PHP-GTK files. Change into the c:\php4\test directory and double click on hello.php. You should see a PHP-GTK window that contains one button. If everything worked OK, then you've successfully installed PHP-GTK.

It might also be a good idea to restart Windows at this point.

Installing PHP-GTK for Linux

I'm going to show you how to download PHP-GTK using PHP's CVS server. Before you can install PHP-GTK, make sure you have PHP version 4.1.1 or later, CVS, and The Linux GTK+ libraries, as well as:

  • libtool 1.3.3 or later,
  • automake 1.4 or later,
  • autoconf 2.12 or later, bison 1.28 or later, and
  • flex 2.54 or later

installed and working correctly.

Firstly, login to the CVS tree using phpfi as your password:

cvs --d :pserver:cvsread@cvs.php.net:/repository login

Next, download PHP-GTK to your machine from PHP's CVS server:

0  
cvs -d :pserver:cvsread@cvs.php.net:/repository co php-gtk

Change into the directory where PHP-GTK was downloaded:

cd php-gtk

Run the phpize tool, which should've been installed when you installed PHP. It should be in the directory pointed to by your phpize path.

phpize

Now you'll need to configure, make and install PHP-GTK:

./configure && make && make install

Lastly, run the following command to execute the hello.php script that was installed when you downloaded PHP-GTK. You should be presented with a PHP-GTK window that contains one button:

php --q test/hello.php

If you liked this article, share the love:
Print-Friendly Version Suggest an Article

Sponsored Links