Written by Jonathan Richter
In an attempt to get PHP-GTK2 to work on Mac OS X 10.4, I found very little information and support on that subject. After a lot of failures and errors I got it to work.
Below I'll write every step I took. I am not very comfortable with Terminal and half of the time I have no clue what I am doing. So you can use this information but totally on your own risk. I just worked for me. I hope it will help anybody else too.
please be adviced that doing all steps below takes several hours.
Resources I found helpful:
Get the newest Xcode (also called: Developer Tools) from Apple. You really need this. Go to connect.apple.com. Sign in or sign up (for free). Go to Downloads.
On the right in the Downloads Box, click Developer Tools and download the newest Xcode. In my case version 2.4.1, 923 MB big. After downloading, use the installer and follow the instructions.
I started with using Fink, but halfway it failed by not having a package that was needed (GTK 2.6 or higher). I started all over using Macports.
Go to macosforge/InstallingMacPorts.
You already did part of the first step by downloading Xcode. I followed all instructions on that page and it worked fine.
The newest version didn't have a normal Apple installer. So I downloaded this: DarwinPorts-1.3.1-10.4.dmg
Install Macports by double-clicking the installer in the disk image.
I already had a standard OS X PHP 4.4.4 installation and a PHP5 installation from Entropy.ch, but it didn't work out. I deleted my PHP5 installation from Entropy.
If you want to run Apache 1 or 2 with PHP4 or 5, Entropy is absolutely the best place to get it.
In Terminal, type: cd / and sudo port install php5
Take a coffee, this takes a while... about 2 hours on my machine. (Macports installs everything in a folder called /opt. I put the "cd /" to place that folder in the root.)
On the other tutorial, you see a --disable-libglade as a parameter for installing PHP-GTK. I don't know why they wrote that. Be very sure that you really don't want Glade. Read about it here: glade.gnome.org.
Check out the screenshots too. I installed without Glade but after a day I did it all over to get Glade working too. If you want to continue without Glade, skip the next step.
For some reason, I got errors doing this. Then I tried again the same in Terminal, but now with X11 open in the background with no errors this time. So, open X11 and hide it (apple-h).
In Terminal, type:
cd /opt sudo port install libglade sudo port install glade |
Instead of using current CVS, you might want to use the latest official version from the PHP-GTK2 download page.
Leave X11 open to be on the safe side. phpize and php-config should be both in /opt/local/bin/. Check that before you run this. In Terminal, type:
sudo cvs -d :pserver:cvsread@cvs.php.net:/repository co php-gtk cd php-gtk sudo ./buildconf --with-phpize=/opt/local/bin/phpize sudo ./configure --with-php-config=/opt/local/bin/php-config sudo make sudo make install |
After it is done, you will see in the output of Terminal a remark about extensions being installed with a path that probably looks like this: /opt/local/lib/php/extensions/no-debug-non-zts-20060613. Apple-c that path or write it down. You will need it later.
In Finder, choose Go > Go To Folder... (or press shift-apple-g) and type /opt/local/etc.
Find the file php.ini-recommended and copy it. Rename the copy to php.ini and open it with - preferably - BBedit.
Find the line extension_dir = "./" and replace it with this: extension_dir = "/opt/local/lib/php/extensions/no-debug-non-zts-20060613" (That path, you copied from the Terminal output in the previous step)
Find the block with all extensions and add this line after them: extension=php_gtk2.so
Save the file.
Start X11 and hide it (apple-h) if not already done.
Start Terminal and type:
cd /opt/php-gtk/demos php phpgtk2-demo.php |
To work with Glade, start it in Terminal like this (with X11 open): /opt/local/bin/glade-2
In my humble opinion: the interfaces in X11 look like crap when you are used to working in OS X. To get other themes, go to art.gnome.org to check them out. In order to use one of those, we need to do one more step.
In Terminal, type: sudo port install gtk-theme-switch
After that is ready, download a theme from the link above. Installing it can be done in two ways:
Move or copy the downloaded .tar.gz (without unpacking!) into /opt/local/share/themes/
Start Glade by typing this in Terminal (with X11 open): /opt/local/bin/switch2
Press the + sign and click the Install New Theme button. Point to /opt/local/share/themes/<your-new-theme-name>.tar.gz
Click OK and now your new theme shows up in the list.
Unpack the <your-new-theme-name>.tar.gz and move or copy the new theme folder to /opt/local/share/themes/
Start Glade by typing this in Terminal (with X11 open): /opt/local/bin/switch2
The name of the new theme should be in the list.