Skip to content

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

October 6, 2009

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

One Comment leave one →
  1. Richard Uschold permalink
    July 19, 2011 8:50 pm

    I have OS X 10.5 .8 too, but my php version is 5.2.12.
    I can’t find php-5.2.12 anywhere on apple’s site, mentioned above.
    Have you any clue how I can find the version I need?

    Thanks

    Richard

Leave a Reply

Fill in your details below or click an icon to log in:

Gravatar
WordPress.com Logo

Please log in to WordPress.com to post a comment to your blog.

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 902 other followers