Recently at work we had the need to install PEAR packages locally to a project rather than globally.
After some research (Google) I happened upon these options - I concede there may be other/better options out there:
- Use a project PEAR configuration file and install packages into the project
- Packages are managed on the project level
- Specify --installroot when installing a package
- Packages are still managed globally
- Wanted to preserve dependency management
- Pyrus appears to solve this issue
- PHP 5.3+
- Each project has its own pear instance
We decided upon option 1 as the packages can be managed effectively on a per-project basis. Although I have seen this method described as "config hell", it has proved to be a good solution so far.
To use a local PEAR configuration file and install packages locally, you can do the following:
mkdir `pwd`/_packagelib pear config-create `pwd`/_packagelib pear-conf pear -c pear-conf channel-discover <channel> pear -c pear-conf install <channel alias>/<package name>
To use the project specific configuration, you must specify the configuration file location as detailed above
pear -c pear-conf ...
From what I've seen Magento do something similar. Have only taken a brief look at their code so need to do some more investigation.
Found PHPiranha / Pearanha by Benjamin Eberlei - https://github.com/beberlei/pearanha . It's a neat tool that automates the process described above.
Additionally, http://pearfarm.org/ looks really useful. They provide an OO interface to generating package.xml.