PHP Pear Advantage is Reusable Code, not Library Management
May 3rd, 2007Whenever I use Pear’s PHP libraries, I cringe at the idea of trying to update a single library of code, shared by multiple applications. Having only one code library to manage was supposed to be one of the big advantages of Pear. But once I install some software, I really try to avoid touching it again for as long as possible.
Whenever I write new code, it just makes sense to use current Pear versions. If I want to upgrade a centralized Pear library, I have to go back and touch all my previous installations that use the library to make sure the Pear upgrade hasn’t broken anything.
To me the better advantage of Pear, is in saving development time by providing a source of reusable code. So I tend to have a separate Pear library for every project that uses it. If a Pear library needs to be upgraded for a security fix, I have to upgrade more than one copy. But this isn’t an issue, because Pear has done such a good job of making their library easy to manage. The upgrade process is automated and pretty quick. The real cost of the upgrade is making sure I didn’t break anything in the code that makes use of the Pear library.
This is the method I use to create individual, project specific Pear installations on my Linux development server.
First, create a separate config file so other Pear installations on the same server aren’t disturbed.
cd /home/mike/project/pear
pear config-create /home/mike/project/pear ./pear.cfg
“/home/mike/project/pear” must start from the root directory and shows the location of the new Pear installation. “./pear.cfg” is the location and name of the configuration file.
To manage the installation, just add this config file to the command line.
cd /home/mike/project/pear
pear -C ./pear.cfg config-show
pear -C ./pear.cfg install cache_lite
pear -C ./pear.cfg list

Traffic data is an unmonetized asset of the Internet. This graph represents the web traffic on MagicBeanDip over the New Years holiday. The red line represents the average traffic over the past month.