PHP-GTK2 Newsletter

PHP-GTK2 Tips & Techniques
FREE Newsletter
by kksou



Sample Code 231: How to install php gtk2 on windows?
Written by kksou   
Monday, 14 May 2007
Problem
How to install PHP-GTK2 on windows platform?
Solution

Updated: March 1, 2008

Thanks to the PHP-GTK2 development team. Installing PHP-GTK2 is now as simple as 1-2-3. Yes, just download - unzip - and off you go!

  1. Download the zip file from http://gtk.php.net/download.php: php-gtk-2.0.0 Windows binary pack

  2. Extract the zip file. You will see a folder called "php-gtk2".
  3. That's it! Yes, that's it! PHP-GTK v2.0 is now ready to run!

Let's do some Test Run

  • First of all, you might want to move the "php-gtk2" folder to a desired location. Let's suppose you moved it to "c:\php-gtk2". Note: hereinafter, I will use c:\php-gtk2 to refer to the folder containing the php-gtk2 application.
  • Next, you might want to set the path to include this folder. I believe most of you have another PHP running for your web server. So when you just type php, most likely it will run the web version of PHP. If you want, you could rename the php.exe in this folder to, say, php-gtk.exe. Otherwise, everytime you want to run php-gtk2, you need to type the fullpath e.g. c:\php-gtk\php script.php.
  • Copy the following script and save them in a file, say "hello.php". Run the script with "c:\php-gtk2\php hello.php". You should see "hello world!" in a window.
  • <?php
    $window = new GtkWindow();
    $window->connect_simple('destroy', array('Gtk','main_quit'));
    $label = new GtkLabel("hello world!");
    $window->add($label);
    $window->show_all();
    Gtk::main();
    ?>
    

  • You may also want to try this script: How to draw a simple bar graph using GD2?
  • and see if you get:

    How to draw a simple bar graph using GD2?


Note
  • If you are new to PHP-GTK2, you can try out PHP-GTK2 with the 400+ recipes available from this site.
  • If you are a seasoned PHP-GTK2 programmer, you may want to check out some of the new exciting PHP-GTK2 Functionalities with this new build of PHP-GTK2.

  • Although you can still use the Gnope Installer to set up PHP-GTK2, the Installer has not been updated for quite some time. And it doesn't include some libraries such as GD2. If you're starting new on PHP-GTK2, I would strongly encourage you to go straight to using the beta release.
  • If you want to add GtkHtml and GtkExtra, please refer to this article: PHP-GTK v2.0 - adding GtkHtml and GtkExtra.

Related Links

Sample Code
Explanation

User reviews   Average user ratings:    3.0   (from 17 users)
  1. nomexous
    May 23, 2007 7:43pm

    Great! These instructions work. I've been trying to figure out how to do it on my own to no avail...

    However, when you set up the php.ini to include the other PHP-GTK extensions (like php_gtk_extra2.dll), it gives me many errors. Mostly they complain about not being about to find php-gtk2.dll. Any idea what that's about?

  2. kksou
    May 24, 2007 8:43am

    Right, I couldn't get php_gtk_extra2.dll to work too...

  3. nomexous
    May 24, 2007 1:34pm

    Well, none of them work except php_gtk_libglade2.dll. I really want to use GtkStatusIcon, and without those extra extensions, it doesn't work. Any suggestion as to how to get them working?

  4. Elizabeth Smith
    May 28, 2007 1:08pm

    Here's some additional hints - you can get a ready to go gtk runtime at http://perisama.net/libs/gtk/gtk-2.10-runtime-full.zip

    That includes everything needed for all extensions, plus the svg pixbuf loader for windows. Unzip that, rename it whatever you want (php-gtk2 is always a good choice), and then dump your php5.2.2-min-all contents inside, put your php-cli.ini in, and away you go.

    php_gtk_extra2.dll had an error in cvs (that's why it wasn't working properly), it should now be fixed. Remember to separate the list of php-gtk2 extensions you want loaded by using commas

    php-gtk.extensions = php_gtk_extra2.dll
    ,php_gtk_libglade2.dll,php_get_libsexy2.dll

  5. kksou
    May 29, 2007 11:03pm

    Elizabeth, thanks for the file gtk-2.10-runtime-full.zip. It simplies the setup a lot!

  6. kksou
    May 29, 2007 11:04pm

    nomexous, Elizabeth has updated the package. It's working now - including GtkStatusIcon and GtkExtra (GtkSheet, GtkPlot, etc.) And she has now made the setup much easier. You just need to download 2 files, unzip, and off you go! I have updated the steps above. Let me know if you bump into any problems.

  7. cBell from USA
    June 21, 2007 2:26pm

    When following the steps outlined above, I kept getting errors about a missing libatk-1.0-0.dll when trying to run the hello world example. What wasn't clear to me was that I not only needed to download the PHP-5.2.2-min-all.zip, but also the gtk-2.10-runtime-full.zip and put them both in the same directory (php-gtk2 in my case).

  8. kksou
    June 21, 2007 7:08pm

    Have just revised the step. Hope it's a bit clearer this time. Just proceed to download those two files - one contains the core php-gtk2 files. The other contains all the required gtk libraries. If you download these two files and put them in the folder as described above, you should not get the error.

  9. dysmas de Lassus from FRANCE
    July 31, 2007 10:14am

    Thanks for this information which is working fine. Just a little note : since you added
    extension = php_mysql.dll
    in the php.ini, probably users will get the error I had about a missing libMysql.dll
    I just added this file in the main directory, and everything is working fine (I have an application which is a gui for a mysql database). This dll is not present in the zip of Elisabeth. I don't know if it is intentionnal or just forgotten.

  10. Tama
    August 03, 2007 1:55am

    Hi, really need help in installing php-gtk2. I tried the instructions above but it complains about not being able to find php-gtk2.dll. Thanks in advance

  11. Tama
    August 03, 2007 2:37am

    Please disgard my first message. PHP-GTK works fine now. I cut and paste the missing dll from another php folder. Cheers

  12. Robert Clancy from Australia
    August 29, 2007 4:37am

    I have tried several times to follow your instructions to the letter.
    When i unzip both zip files to c:/php-gtk2 i get the directory structure

    c:\php-gtk2
    . . .ext
    . . .gtk-2.10-runtime-full
    . . . . . etc
    . . . . . lib
    . . . . . share

    Then not even hello.php will work.
    Where am i going wrong?
    Thanks for all the info.
    Extremely valuable.
    Rob

  13. kksou
    August 29, 2007 8:48am

    Hi Robert, if you have installed php-gtk2 in c:\php-gtk2, open up a cmd window and type: c:\php-gtk2\php -vWhat did you see? Any error message?When you follow step 6 above "c:\php-gtk2\php hello.php" (please type the full path and not just php hello.php), what error message did you get? If it's still not working, please drop me a message via the feedback form. I'm more than willing to help you zoom in where's the problem via email. Regards, /kksou

  14. Robert Clancy from Australia
    August 30, 2007 4:35am

    Tx for your response. . . Keying in c:\php-gtk2\php -v . . . gave me . . . PHP 5.2.2(cli) . . etc. . (built: May 29 . . etc . . . Copyright . . . etc . . .
    Zend Engine v2.2.0. Copyright . . etc . . . From a random directory, keying in . . . c:\php-gtk2\php c:\php-gtk2\hello.php. . . gave . . . Fatal error: Class 'GtkWindow' not found in c:\php-gtk2\hello.php . . . In the install steps you say 'dump' everything into c:\php-gtk2\, and i don't know exactly what that means in detail. I took it to mean 'unxip' everything to c:\php-gtk2\ as the base directory. It bothers me that i have not ended up with your exact directory structure. . . . I recently got hello, bargraph and other test programs going, but that was by grabbing chunks of files from various folders, and copying them into c:\php-gtk2\.
    I did not manage however to get Scribble going.
    I had to go back to php4 to get that one to work. . . . My real aim in all this is to write a drawing program with lines, circles, importing existing images, etc
    in black and white, a bit like PaintDotNet.exe, then be able to write an image of it to a file for later printing. If it turns out that i can't do it using PHP i'll have to resort back to java. . . Looking forward to a clean install with your assistance, for which i am grateful.. . Cheers, Rob

  15. kksou
    August 30, 2007 8:04pm

    Hi Robert, I did another round of test of the various installation packages available, and found the beta-release available from the official php-gtk2 site the easiest and fastest. I've just revised this article. Now 2 steps only - download and unzip. That's it! Please give it a try and let me know if it works. Regards, /kksou

  16. Rob Clancy from Australia
    August 30, 2007 10:27pm

    Brilliant!. . . I followed your 2 steps and everything works. . . This is what i did in detail as it may help someone out there . . . Create 2 empty directories c:\phpEmpty and c:\php-gtk2 . . . Click on the link at http://gtk.php.net/download.php as directed in Step 1. . . Choose the Save option and save in c:\phpEmpty. . . In the 'Download Complete' dialogue box choose Open which automatically loads WinZip. . . Ctrl-A to select everything in the zip file. . Extract to c:\phpEmpty. . . This will create a subdirectory in phpEmpty named php-gtk (as in Step 2). . . Select this new subdir in the left-hand panel of your browser which will list out all the contents in the right-hand panel. . . Highlight everything in the right-hand panel and drag the lot to c:\php-gtk2. . . Install complete. . . By the way kksou, your bargraph probably gives me everything i am looking for. . . I have some experience in Visual C++ and Java but have just purchased your Demystified book on approval. . . Keep up that enthusiasm, Rob2168

  17. ryannining
    June 05, 2008 5:59am
    help

    please help me for install it in linux.thanks

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Copyright © 2006-2008. kksou.com. All Rights Reserved