PHPGTK-application window

PHPGTK is an extension to PHP that allows you to create graphical user interface (GUI) applications. Instead of running in a browser, your PHP application runs in its own application window. These applications are client-side only. They do not reside on the Web server. The files instead reside on the user's hard drive. For users to use the PHPGTK application, they must have the proper version of PHP with the GTK+ extension installed on their system.

GTK+ was originally designed for the open-source image editing program called the GIMP (GNU Image Manipulation Program). GTK stands for the GIMP Tool Kit. Later, the Gnome team decided to use GTK+ to create their desktop environment for Linux. GTK+ has been ported to Windows, Linux, and BeOS, and thus makes for a good cross-platform GUI library.

PHPGTK uses GTK+ to draw the widgets required in any GUI application. Widgets are things like scroll bars, text input fields, and buttons, among other things. When you start almost any Windows application, such as a Web browser, you are looking at a collection of widgets.

Widgets need to be contained in some type of framework to be useful and logical. You can't just have a bunch of buttons and text fields scattered randomly about the screen. To solve this problem, we use a special kind of widget called a container. A container is another structure that organizes the widgets however you think it best for your application. For example, the menu bar at the top of most applications is a container.

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 
 

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.
 


Related Posts:
  • php Sessions page Php Sessions are used to help maintain the values of variables across multiple web pages. This is done by creating a unique session ID that is sent to the client browser. The browser then sends the unique ID back on eac… Read More
  • The $_REQUEST Variable-php PHP is a lot more than a way to work with text. You’ve been working with strings non-stop, but there are a lot more types of information you’ll need to work with in your PHP scripts. As you might expect, there are all kinds … Read More
  • socket tcp server with php Php Web Application Php Email Codes Php Array Php Ifelse Php variables Php Substrings Php Mysql Functions php-sessions HTTP is the standard that allows documents to be communicated and shared over &nb… Read More
  • PHP identical operator === Variable types are also important in comparison.When you compare two variableswith the identical operator (===), like this, the active types for the zvals are compared,and if they are different, the comparison fails outright… Read More
  • Get mail info with IMAP or POP3 To read mail using IMAP or POP3, which allows you to create a web-based email client. Use PHP's IMAP extension, which speaks both IMAP and POP3: // open IMAP connection $mail = imap_open('{mail.server.com:143}', &nb… Read More
  • Adding CSS style in php script <?php       echo '<span style="font-size:10px">';    // add  styles as  style attribute       echo 'test';     &nbs… Read More
  • Php tutorial - imagemagick Php tutorial - imagemagick Php tutorial - imagemagick - create, edit and compose bitmap  imagemagick is free software  to create, edit, and compose bitmap images in many formats from the commandline or via progra… Read More
  • Send Email from a PHP Script you use the mail() function (in combination with a web form in particular), make sure you check it is called from the desired page and protect the form with a CAPTCHA mail(to,subject,message,headers,parameters); <?php… Read More
  • Displaying Browser Specific-php However, having seen some of the possible values of HTTP_USER_AGENT in the last chapter, you can imagine that there are hundreds of slightly different values. So it's time to learn some basic pattern matching.You'l… Read More
  • difference between print and echo - php print( ) is a function, echo is a language construct.  This means that print( ) returns a value, while echo doesn't. You can include print( ) but not echo in larger expressions. echo is  run very fast than  … Read More
  • Third-party Cookies Third-party Cookies Third-party cookies come from other domain sources that have items, such as ads or images,  embedded on the page adjust cookie and site data permissions. Manage your cookies and site data - chrome … Read More
  • php-use the header() function-php An HTTP (HyperText Transfer Protocol) header is used to send information back and forth between the server and the client (the Web browser). Normally this information is in the form of HTML, which is why the address for Web … Read More
  • Creating a Simple Php Functions #menu111 { BORDER-RIGHT: #cccccc 1px dashed; PADDING-RIGHT: 20px; BORDER-TOP: #cccccc 1px dashed; PADDING-LEFT: 20px; BACKGROUND: #dddddd; LEFT: 20px; PADDING-BOTTOM: 20px; MARGIN: 0px; BORDER-LEFT: #cccccc 1px dashed; WID… Read More
  • Php session Info and cookies #menu111 { BORDER-RIGHT: #cccccc 1px dashed; PADDING-RIGHT: 20px; BORDER-TOP: #cccccc 1px dashed; PADDING-LEFT: 20px; BACKGROUND: #dddddd; LEFT: 20px; PADDING-BOTTOM: 20px; MARGIN: 0px; BORDER-LEFT: #cccccc 1px dashed; WI… Read More
  • php -Mail Functions The mail() function requires an installed and working email subsystem for sending mail. The program to be used is defined by configuration directives in the php.ini file. A common pitfall is that these are not set up cor… Read More