Installing PEAR for PHP on OSx

Along your PHP travels you will hear noises relating to installing something from PEAR to help you with some PHP snizz.

PEAR is simply a code repository, in fact PEAR stands for PHP Extension and Application Repository.

Installing it is a breeze assuming you already have php installed (you can verify this by typing php -v into your command line).

The first thing to check is that it isn't already installed — a quick command will verify; pear version. If this brings back version information then you are good to go, if it reports Command not found then follow these simple steps.

Download the phar file at this location:

Run PHP on the file, so if you downloaded it to your Downloads folder then run sudo php go-pear.phar.

You will be asked some installation questions, I quite like the defaults but feel free to change whatever you want.

Next if you have accepted the defaults you will probably want to add PEAR to your path so that you can call it easily from the command line. I like to do this in vi but there are several ways to achieve it;

I run sudo vi ~/.profile and add in my PATH to the bottom of the document; export PATH=/Users/YOUR_USER_NAME/pear/bin:$PATH, I then reload my profile with . ~/.profile and that is me, now if I run pear version I get version information.

Recent posts View all

Simple CS

Abstract Syntax Trees

Let's learn about Abstract Syntax Trees, what they are and why we need them.

Talk CSS

FrontEnders - Web Performance

Sharing some of my thoughts on a FrontEnders meetup on the topic of Web Performance