tags:

views:

347

answers:

3

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?

+1  A: 

I'm note entirely sure if this answers your question, but you can specify the location for the PEAR repository on the commandline, so you can create a local repository, using:

pear install --force --installroot=/path/to/my/pear/ PEAR

Then you can install additional packages using:

pear install --installroot=/path/to/my/pear/ SomePackage

To use the local repo from within your app, you have to make sure that the include_path points to the local repo, rather than the default (globally installed) repository. So you'd want it to look like this:

include_path = ".:/path/to/my/pear/usr/share/php"

Re :

Actually, he wants to avoid the absolute paths so that the solution can be checked out from many machines without depending on the path each one has the repository installed.

-- Carlos Lima

Seems you're right. In that case, I would advice that you don't check the PEAR repository into your SVN repository, but rather use a deploy script to install/update the repository at the server. Just make sure to install a particular version. (You do have an automated deploy, right?)

troelskn
Actually, he wants to avoid the absolute paths so that the solution can be checked out from many machines without depending on the path each one has the repository installed.
Carlos Lima
Yeah maybe that's what I need to do. (It's amazing though that this is actually a problem... there is no way I am the first to want to bundle PEAR packages along with my project in order to ensure the right dependencies are available...)
Sean
+2  A: 

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.

1. Create a remote.conf file

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

2.Update the channels

$ pear -c remote.conf channel-update pear.php.net

3. install PEAR

$ pear -c remote.conf install --alldeps pear

4. install any other libraries

$ pear -c remote.conf install --alldeps <libname>

Voila... PEAR is part of the source tree.

The Catches:

  • Even though the paths in 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.
  • Some libraries don't like being outside the path, so you may have to add vendor/PEAR to the path (I've got code, just ask if you need.)
MDCore
Hi,the remote.conf file still seems to contain absolute paths?Also, all steps after the first one yield the error about the various sub-directories not existing (like tmp, .registry, etc.)
Sean
Doh! yeah, I meant "absolute" under catch #1 and not "relative." I'm not sure about the error's you are getting ... what platform are you on, and is your PEAR up-to-date?
MDCore
+1  A: 

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.

saltybeagle