Skip to content

Building new modules for built-in PHP on OS X / installing SoapClient on OS X

October 6, 2009
by David Mytton

I do all my development on Mac OS X and use the built in, Apple supplied PHP for that. This works nicely with the built in Apache and MySQL and means I don’t have to install 3rd party software unnecessarily (e.g. MAMP which is rarely updated).

However, this brings a few complexities because the Apple supplied PHP is pre-compiled with a number of modules excluded. One of these is the in-built Soap client in PHP 5 which I use for interacting with web services, specifically those of our payment gateways.

It is actually not difficult to install modules and having had to do this last night with Soap, it would be useful to write up the instructions that I had to spend time researching:

1. Download the latest PHP source from Apple

This can be done from the Apple Open Source website and ensures that the source you are building matches that provided with the OS version you are running. In my case, I am using OS X 10.5.8 so the download is from this directory, specifically php-5.2.8.tar.bz2.

2. Extract the source

3. Browse to the Soap extension source directory within the PHP source directory

cd ext/soap

4. Set compilation paths

export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin
export LIBTOOLIZE=glibtoolize MACOSX_DEPLOYMENT_TARGET=10.5

5. phpize

phpize

6. Run ./configure with a number of compile flags

CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -pipe -no-cpp-precomp -arch ppc -arch ppc64 -arch i386 -arch x86_64" \
CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" \
CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe" \
LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64" ./configure

7. Compile

make
sudo make install

8. Enable extension

Add extension=soap.so to your php.ini file.

9. Done!

Restart Apache and you’re done.

References:

http://lists.apple.com/archives/macos-x-server/2007/Nov/msg00304.html
http://www.entropy.ch/phpbb2/viewtopic.php?p=12785#12785

No comments yet

Leave a Reply

Note: You can use basic XHTML in your comments.

Subscribe to this comment feed via RSS