I'm working on a project that'll use PEAR packages. Because you never know what version of the PEAR package will be installed on your hosting provider (and especially because I require a patch to have been applied to one of the packages), I'd like to put the PEAR source for my project right into SVN, so other developers can immediately have the dependencies.
But everything related to PEAR seems to have absolute directories! Running "pear config-create . pear.conf" to set up a new PEAR directory even fails with the error message:
Root directory must be an absolute path
I checked out the pear config files on some other servers and they, too, seem to have absolute paths.
Whenever a developer checks this out to his own machine, or we export it all to a server, we don't know what the absolute path will be.
Is there any way to set this up?
If you have PHP 5.3.1 use Pyrus, the PEAR2 installer. The pyrus managed installations can be moved where ever you like.
Download pyrus -
$> wget http://pear2.php.net/pyrus.phar
Create a directory to store your pyrus-installed packages:
$> mkdir mylibs
Install packages -
$> php pyrus.phar mylibs install pear/Net_URL
Your installed package is now at mylibs/php/Net/URL.php
Note that we passed the mylibs directory to indicate what directory to install to, as well as the channel name 'pear' (the default in pyrus is pear2.php.net). For convenience, the pyrus.phar file can be executed from cli if you chmod +x it.
You can move the mylibs
directory wherever you'd like. Even commit it to your repository.
Lots of docs on the PEAR website.
I couldn't get my Hosting provider to install the PEAR libraries I wanted. Here's how I made PEAR part of my source tree.
Creating your remote.conf is a little different than in the manual. Lets say I want to install PEAR in vendor/PEAR
of a project. You would do it like this:
#from the root of the project
$ cd vendor ; mkdir PEAR ; cd PEAR
$ pear config-create <absolute path to project>/vendor/PEAR/ remote.conf
$ pear -c remote.conf channel-update pear.php.net
$ pear -c remote.conf install --alldeps pear
$ pear -c remote.conf install --alldeps <libname>
Voila... PEAR is part of the source tree.
remote.conf
are absolute the libraries themselves will still work. It's just updating that won't work from anywhere. You will need to update it from the same path that it was created from -- in the above case, from vendor/PEAR
.vendor/PEAR
to the path (I've got code, just ask if you need.)If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With