Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add PEAR packages to Subversion repository?

Tags:

php

svn

pear

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?

like image 631
Sean Avatar asked Jun 28 '09 18:06

Sean


2 Answers

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.

like image 20
saltybeagle Avatar answered Sep 28 '22 22:09

saltybeagle


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.)
like image 138
MDCore Avatar answered Sep 28 '22 22:09

MDCore