MAMP + PEAR + tcsh

Technical

Having chosen MAMP as my Apache, MySQL & PHP stack of choice on the Mac, things have been rolling along pretty well. Well, until tonight. Tonight was the first time I've had a need to connect to a database since I started developing locally. I've been building out the domain model of a project for the past few weeks and now it's time to establish persistence. Since I've used PEAR::MDB2 for database abstraction in the past and am reasonably comfortable with doing so, I decided to just stick with it (one of these days I'll get around to trying out PHP's baked-in data objects). Using MDB2, though, means that I need a working installation of pear. MAMP comes with pear installed, but it's not necessarily configured and happily ready to run. Mine most certainly wasn't. When I tried to install the MDB2 package, i got the following error:

$ /Applications/MAMP/bin/php5/bin/pear install MDB2

dyld: NSLinkModule()

errordyld: Library not loaded: /Users/severin/Dev/Projects/MAMP_1.7_src/lib/libltdl.3.dylib

Referenced from: /Applications/MAMP/bin/php5/lib/php/extensions/no-debug-non-zts-20050922/mcrypt.so

Reason: image not foundTrace/BPT trap

Um, huh? A little light caressing of the Google monster turned up several mentions of the solution, but all were bash-centric. My preferred shell is tcsh (a legacy preference that I'm considering changing), so I needed to do something slightly different. In my ~/.tcshrc file, I had to add the following line:

setenv DYLD_LIBRARY_PATH /Applications/MAMP/Library/lib:${DYLD_LIBRARY_PATH}

And then run:

$ source ~/.tcshrc

Now pear is happy again. I haven't done it yet, but I'll also have to add the path to my pear modules to my include_path in php.ini so I don't have to reference the entire path every time I use a package in my application. For MAMP (using php5), that path is /Applications/MAMP/bin/php5/lib/php.

Note that OS X comes with its own copy of pear that is not the same as, and cannot be used as a replacement for, MAMP's. When executing pear, always do so from the MAMP path. Another solution is to rename the baked in executable and create a symbolic link to MAMP's. I'll leave it up to readers to select and figure out their preferred option.

tags:
PHP, M/W/LAMP, pear

Search

Rob  Wilkerson