PHP Extension & Application RepositoryPyrus - A few PEAR Compatible Packages

Switching Local PEAR Installations

Installing multiple pear repositories and switching between them may be a little bit more complicated than just calling "pear config-set php_dir /path/to/your/pear". Other settings may need to be set, environment variables changed and the repository's meta-files may need updating. Here are the following issues I picked up on:

  1. I like to set the following configuration settings: php_dir, doc_dir, test_dir & data_dir. Doing this avoids permission problems if you aren't superuser and you may want to link to some of the data files locally, run tests after deployment to a live machine, etc.
  2. As you progressively update each of the pear installations, the global pear installation will become obsolete, therefore you'll need to update the environment variable $PHP_PEAR_INSTALL_DIR so that it will reference a more up to date pear installation.
  3. The hardcoded include_path in pearcmd.php will also need to be updated.
  4. When moving the local installations around, say due to of the use of version control or by cloning for use in another website, the installation's meta-files will need to be updated. The installation's registry files store file information with absolute pathnames. These filenames are used for things like deletion, when removing packages.

This solution maybe a little bit convoluted but it works and saves me a few headaches. I've got here a short shell script, a php script to update the meta-files and an alias you can add to your bash profile.

Shell script: pear-switch

PHP script: convert_pear_registry.phps

Invoking the shell scipt normally will not update the pear location environment variable, because of the fact that child processes aren't allowed to modify their parent process's environment. Source needs to be run with the script instead. Rather than calling source on my pear-switch script all the time, I've created an alias in my .bashrc:

alias pear-switch="source $HOME/bin/pear-switch"

The alias is then called with the argument of the location of your pear installation:

pear-switch /path/to/your/pear

 

 
SourceForge.net Logo