How to Install Phing on MAMP (Mac OS X Catalina)

My PHP test server is a MAMP installation. I recently decided to upgrade my Mac OS X to Catalina, and upgraded my MAMP installation to version 5.7. This allowed me to test my code on PHP 7.4.2, and since I use Phing, I needed to reinstall it on the new PHP 7.4.2 instance. I encountered an interesting error (or technically, a notice) that I found to be very annoying, and misleading. I want to share the fix with you, and go through the steps of installing Phing together.

Phing is installed using PEAR. The first thing you need to do is to navigate to the location of PEAR on your MAMP 5.7 installation on Mac OS X Catalina. We will be concerned with the location of the PEAR executable and also where the lib files are located.

Step 1 – Fix the REST.php file

Open a Finder window, and navigate to the following location: /Applications/MAMP/bin/php/php7.4.2/lib/php/PEAR. Open the REST.php file in your favorite text editor. Go to line 181, and make the following change:

Basically, we are adding $cacheid && to the beginning of the if statement. This facilitates handling the use case of where the getCacheId function returns false when there is no cache file.

If you don’t patch the REST.php file, then you will get the following message when you install Phing from PEAR, and it will be repeated numerous times during the installation process:

Step 2 – Update your PATH variable

Before we install and test Phing, let’s setup the Terminal shell to respond to typing “phing”. With Mac OS X Catalina, Apple has changed the default shell from bash to zsh. Adding the location of phing to either bash or zsh involves editing the .bash_profile or the .zshrc, respectively. The change we make to either of these files are exactly the same. Depending on which shell you use, you will choose which file to edit. Both of these files will be located in your user home directory. Open your Terminal app, and enter the following commend in your bash or zsh prompt to go to your home directory immediately:

If you are using bash, edit the .bash_profile file:

If you are using zsh, edit the .zshrc file:

In vim, press i to insert text in the file, and type the following:

To save the changed to the file. Press [ESC], then type :wq and press [ENTER].

Step 3 – Install Phing and Use it

Open a new Terminal window, and enter the following command in your bash or zsh prompt then press [ENTER]:

Type the command, “./pear channel-discover” to make sure that PEAR can find the Phing package then press [ENTER]:

Once the Phing channel was successfully discovered, type “./pear install phing/phing” to install Phing:

After Phing is installed, you will see massage that confirms a successful installation:

Lastly, open a new Terminal window, and type “phing -v” to test your setup. It should display the version of Phing that was installed:

Leave a Reply

Your email address will not be published. Required fields are marked *

Recent Posts



Users Online

1 User Browsing This Page.
Users: 1 Bot


GiottoPress by Enrique Chavez