MAMP and PEAR

I finally added some PEAR packages to my MAMP Pro installation. Theoretically you should be able to use the PEAR installer that comes with MAMP. I’ve used the PEAR installer on other servers, but couldn’t get it to work on the local development environment on my Mac. I’ve found a few posts from MAMP users who recommend using the installer, but if any of those users got it to work on their own systems, they didn’t share the details of how they did it.

Success came by following a manual process similar to that copied from the Neo Geek article below, Setting up MAMP, PEAR, and Headress:

PEAR Installation

  1. After locating the framework you want on pear.php.net, download the latest version (or the version you need for testing) from the "Download" tab on that framework's main page.
  2. Unzip the downloaded file.
  3. Open the folder that was extracted to find another similarly named folder and a file named package.xml.
  4. Copy just the folder to Applications/MAMP/bin/php5/lib/php/. (I copied just the contents of that folder to the HTML folder in my example below.)

Notes on Step 4: 1) If you are using MAMP Pro, you still install your pear packages in the MAMP path shown. 2) There is a PEAR folder in Applications/MAMP/bin/php5/lib/php/ PEAR packages you add manually go in Applications/MAMP/bin/php5/lib/php/ not in Applications/MAMP/bin/php5/lib/php/PEAR/

I didn’t want to change include statements in the scripts I was testing. Instead I created a folder in Applications/MAMP/bin/php5/lib/php/ for the top level package name, HTML in this case, and copied the files in the extracted package folder into the HTML folder. So for HTML_Common there is a file named Common.php in my Applications/MAMP/bin/php5/lib/php/HTML/ folder. If this path structure doesn’t work for you, refer to the error messages PHP is generating to help you figure out where to locate packages.

Leave a Reply