Installing PHP-Gtk and PHP 5.2 and Pear on Windows in April 2010

After battling for some hours I have managed to install php-gtk with PHP  on my Windows XP machine.

I am following the book PHP-GTK by Scott Mattocks - but the installation instructions are slightly out of date (book was published a few years ago) .

It took four attempts and i still have not managed to get a pecl command to install bcompiler or  pdflib - but everything else is working.

Although I am really tired and just want to rest now, i am scribbling these notes so I do not forget how i did it.

PiGii Installer

I used a handy installer which i got from here:

http://sourceforge.net/apps/mediawiki/pigii/index.php?title=Main_Page

I chose the ‘HUGE’ version which also includes Glade.

During installation, I left it to install the various components into my Programs folder:

C:\Program Files\PHP-GTK.201

I also ticked the option to install PEAR (plus some other goodies)

Setting the PATH Environment Variable

Based on the description on the php.net site: http://php.net/manual/en/install.windows.commandline.php

In order to tell Windows the location of the PHP exe I did the following:

Start >  Control Panel > System > Advanced > Environment Variables

Then, in the System Variables pane I scrolled down to the ‘Path’ variable and double clicked on it and added:

;C:\Program Files\PHP-GTK.201

Then I clicked OK

This meant that I could open up a demo. I did this by, first launching my command line like so:

Start >  Run...

I typed : “cmd” then Clicked “OK

This opened up the command window

Then I typed:

#php -v

(# is my sign for a ‘command prompt’)

to see the version of php

Then I typed

#  php "C:\Program Files\PHP-GTK.201\demos\phpgtk2-demo.php"

That opened up a demo php GUI application. Hooray.

Associating .phpw extensions with php_win.exe to make it easier to launch php GUI apps with a double click

Next I wanted to  make it easy to launch php GUI apps with a double-click. This is done by associating files ending with the “.phpw” extension to the “C:\Program Files\PHP-GTK.201\php_win.exe”

First I typed:

#assoc .phpw=phpwfile

Which gave the output:  “.phpw=phpwfile

Then I typed:

#ftype phpwfile="C:\Program Files\PHP-GTK.201\php-win.exe" -f "%1" -- %~2

Which gave the output:  “Associating .phpw extensions with php_win.exe”

I then made a  “hello world”, php-gtk script “helloworld.phpw”:

————–

<?php

//phpinfo();

$window = new GtkWindow();

$window->connect_object('destroy', array('gtk','main_quit'));

$window->show();
gtk::main();


—————

and double clicked on it - it launched OK.

Hooray.

(Although I discovered that “connect_object()” is a deprecated method name)

Next, in chapter 2 of the PHP-GTK book, Scott talks about installing some PEAR packages; Mail_Mime and Console_Getargs

But I had not yet got the Pear installer working, so:

Installing the Pear installer

The pear website talks about running the  “go-pear.bat” script to install Pear. But many other sites talk about the “PEAR/go-pear.phar” file. I had already used the “bat method” 3 or 4 times and had all sorts of weird outcomes. So what was it to be?  Install pear via go-pear.phar or go-pear.bat?

I looked into the “go-pear.phar” method, but did not like the locations it was suggesting. So I exited and went for the .bat.

I double-clicked on:

"C:\Program Files\PHP-GTK.201\go-pear.bat"

A command window launched and it asked if i wanted to go system-wide or local.

I chose “local”, cos I did not like the idea of Pear littering itself throughout my system.

I went through the various options, saying yes to everything else it suggested (adding the include path into my CLI ini) and, when done, closed down the command window.

I then tried Pear  out. I typed:

#pear upgrade-all

to upgrade any stuff

then, to follow the book:

# pear install-a Mail_Mime

and

# pear install-a Console_Getargs

Both worked OK.

Then i tried to run the pecl installs (p. 22 of the php-Gtk book):

#pecl install bcompiler

However that failed with the message:

"Failed to download pecl/bcompiler within preferred state "stable", latest releas
e is version 0.9.3, stability "beta", use "channel://pecl.php.net/bcompiler-0.9.3" to install

install failed"

I then tried

#pecl install bcompiler-0.9.3

But, that also failed with a whole load of errors

I gave up on that. Then tried:

#pecl install pdflib

Again, it came back with a load of errors:

———

#pecl install pdflib
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-upd
ate pecl.php.net" to update
downloading pdflib-2.1.7.tgz ...
Starting to download pdflib-2.1.7.tgz (55,997 bytes)
.............done: 55,997 bytes

Warning: rename(C:\DOCUME~1\Me\LOCALS~1\Temp\pear\temp\pdflib\.tmpconfig.m4,C:
\DOCUME~1\Me\LOCALS~1\Temp\pear\temp\pdflib\config.m4): File exists in PEAR\In
staller.php on line 679

..etc...

11 source files, building
WARNING: php_bin C:\Program Files\PHP-GTK.201\.\php.exe appears to have a suffix
.exe, but config variable php_suffix does not match
running: msdev pdflib.dsp /MAKE "pdflib - Release"
ERROR: Did not understand the completion status returned from msdev.exe.

———-

I gave up.

So, I got it everything working OK apart from the pecl installer. And after hours of hacking  - I could not care less about that bloody pdflib any more!

Although its not perfect, in some ways I’m pleased to be able to make and be able to run my own GUI apps using PHP. I’m sure i will work out pecl some other time.

4 Responses to “Installing PHP-Gtk and PHP 5.2 and Pear on Windows in April 2010”

  1. Pete Says:

    Hi,

    I’m using same book and having exactly same troubles..

    I got to where you did with pretty much no problems, then when it came time for pecl… the proverbial hit the fan :-(

    Anyone out there shed any light on this would be very much appreciated.

  2. Same Says:

    Hi guys,

    try pecl install bcompiler-beta instead of pecl install bcompiler-0.9.3, it worked very well for me.

    Peace !

  3. John Says:

    Thanks Same.
    Getting bcompiler-beta working is not at the top of my to-do list right now. But I will give that a shot when the time comes, so thanks for the helpful tip.

  4. Akash Says:

    Hi Same,

    pecl install bcompiler-beta ; did not work in my case, got a whole lot of warnings though.

    Any alternative or update on the pecl install

    Thanks,
    Akash

Leave a Reply