Install PEAR on macOS 10.15 Catalina

macOS now no longer ships with PEAR, but installation is quite easy.

Prerequisites

Install PEAR

cd /tmp
curl -s -O https://pear.php.net/install-pear-nozlib.phar
sudo php install-pear-nozlib.phar -d /usr/local/lib/php -b /usr/local/bin

Upgrade PEAR

sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net
sudo pear upgrade-all --ignore-errors

Configure PHP

First, you have to find out which php.ini you’re using.

php --ini

Find the “Loaded Configuration File:” line. If no php.ini file is loaded, you can create one at /etc/php.ini with the following contents:

include_path = ".:/usr/local/lib/php/pear"

You can double confirm the newly created php.ini is loaded by issuing the second last command.

Update PEAR and PECL channels

After a fresh installation, channels need to be updated.

sudo pear channel-update pear.php.net
sudo pecl channel-update pecl.php.net

Done!

You can now use the PEAR and PECL.

Questions?

Please leave a comment below.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Raptor Kwok

I write stuffs: novels, programs, mobile apps, journal papers, book chapters, etc.