When PEAR first came out I wasn’t very impressed. Although it still has issues, some of the modules are quite handy (if you haven’t looked at HTML_QuickForm do so now). I’ve been working on a couple of projects where I want to have all of the code, including PEAR modules, together so that it can be used without having to worry about additional dependencies. The simple way to do this is to download go-pear, install it with php go-pear local
and change the directories to install PEAR with your project code. Simple enough, but things didn’t work the way I expected out of the box. Here are some additional details that I learned the hard way.
When doing a local install PEAR will create a pear.conf file containing the paths you told it to use during install. In order to make use of this file, you have call pear with the -c option, like this:
pear -c /path/to/pear.conf ...
Until I figured that out the pear command kept trying to make use of the system install of PEAR. I believe the default location for the pear.conf file is what ever your configure $prefix to be during the install. Assuming that the pear script is installed in $prefix/bin, calling pear with pear -c ../pear.conf
seems to work just fine.
The next problem I ran into was trying to get Spreadsheet_Excel_Writer installed. This module isn’t available under the stable tag, only the alpha tag. I didn’t want to change the default tag to alpha, so that is where the -d option came in. The -d option allows you to override a default configuration, like so:
pear -d config_parameter=newvalue
To install a module under the alpha tag you would use pear -d preferred_state=alpha install module_name
.
I was surprised when I was unable to find this information in the PEAR Manual, instead I had to hunt around Google picking up pieces here and there.
One reply on “PEAR Command Line Options”
Hi Joseph,
Your post help me to understand where is the pear.conf. It is so obvious, but I spent days googling. Thanks for the hint — it is installed in where I installed PEAR when doing a local installation of PEAR.
I copy the pear.conf and renamed it as pear.ini and put it under C:Windows (default path for PEAR index.php to start the webbased PEAR package manager on my local server). Using this webbased PEAR package manager is a lot more convenient to manage PEAR.
Thanks again!
KYC