Easy Pear Installation | Install pear package on Mac OSX

Pear was problem 😓

I am a PHP & WordPress developer and just shifted to mac first from windows than Linux. More or less I know that OSX is a Unix-based command line.

Now I need Pear to get installed on my Mac to install Phpcs for code formatting and code standardization.  I searched a lot and found many tutorials but seems non-work well for me so after gone through deep google search and exploration for pear installation on mac. I thought why not to make one specific helpful tutorial for mac beginner.

How to Install Pear package on Mac?

To Install pear on mac OSX the following step needs to get followed.

Step 1: come to home directory with cd command
i.e your user home directory

Step 2: Check if you have pear

pear version

Step 3: Use curl as shown below to download the go-pear.phar file or just download the go-pear.phar file via your browser.

$ curl -O https://pear.php.net/go-pear.phar
$ php -d detect_unicode=0 go-pear.phar

You’re now ready to configure PEAR for installation

Step 4: First you need to change the Installation Base

Don’t forget to follow these two steps here

  • So type 1, and then press Enter
      •     Enter /usr/local/pear
      •    Press Enter

Then, you will need to change the Binaries directory.

  • Type 4, and then press Enter.
      • Enter /usr/local/bin
      • Press Enter.

Step 5: Once you have changed the Installation Base and the Binaries Directory, press Enter to install PEAR.

Step 6: Now pear is installed and one thing remaining is you will have to add it in system environment variable path
you can add this in your .bash_profile which is an invisible file in your home directory.

 

check the pear path by command

which pear

It will show you path like this

/Users/USERNAME/pear/bin

Step 7:  So Now go to Home directory first using cd command and open .bash_profile

vim .bash_profile

Step 8:  So the PATH variable line will look something like this, each path is separated by a colon and finished with the variable $PATH, in the example below the pear path is the 2nd one

export PATH="/Users/USERNAME/pear/share/pear/:$PATH"

Don’t forgot to change username with your username in export path of pear.

Step 9: Refresh the profile

source .bash_profile

Step 10:  Verify

pear version

you will get installed pear version on terminal.

 

If you want to explore more you can check these links listed below

https://coolestguidesontheplanet.com/installing-pear-on-osx-10-11-el-capitan/

http://pear.php.net/manual/en/installation.getting.php

Leave a Reply