Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using PEAR with MAC OS X

Tags:

php

macos

pear

I've tried using pear to install both phpunit and phpdoc and seem to be running into a problem with my pear installation.

following the installation guide here :

  1. You can prepare your PEAR installation using the following commands: $ pear channel-discover pear.phpdoc.org

this gives me an error message: -bash: pear: command not found

I've seen mention of using $ locate bin/pear to find the installation. This gives me the following message:

WARNING: The locate database (/var/db/locate.database) does not exist.
To create the database, run the following command:

  sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist

Please be aware that the database can take some time to generate; once
the database has been created, this message will no longer appear.

Not sure what that means, but if I'm reading it correctly, it's saying that pear isn't there. I know my path to pear is /Applications/MAMP/bin/php/php5.3.6/bin/pear /Applications/MAMP/bin/php/php5.3.6/bin/pear.

I'm a little lost on what to try next. Any suggestions on what I'm doing wrong?

like image 951
TH1981 Avatar asked May 11 '12 23:05

TH1981


2 Answers

Create your locate database using the command given. You can think of this in terms of the way spotlight has to "load" or index everything when you first install osx. 'can take some time' usually means 'will take some time'

If you know your pear path you can execute it directly:

/Applications/MAMP/bin/php/php5.3.6/bin/pear channel-discover pear.phpdoc.org

or add an alias to it manually in your bash profile directory http://blog.elucidcode.com/2011/03/terminal-aliases-in-os-x/

or make a link to it in /usr/bin.

For an overview. It seems pear is installed fine. Just when you type in 'pear' into the console osx doesn't recognize that as being a command, Its like a shortcut on your desktop that doesn't point to anywhere. What needs to be done (using one of the methods above) is to point the "desktop shortcut" (the pear command) to the actually pear binary.

like image 197
dm03514 Avatar answered Sep 18 '22 02:09

dm03514


Try using the full path to pear:

$ /Applications/MAMP/bin/php/php5.3.6/bin/pear channel-discover pear.phpdoc.org

When you enter a unix command like that, the first part is the application that you want to run. Typing "pear" means you want to run the pear app. Your OS knows a few directories in which to look for applications. You can see what they are by entering the command:

echo $PATH

The list is separated by colons. If the application you want to run is not in one of those folders, then your OS doesn't know where to find it. It won't automatically search your entire hard drive to find an application of that name. That would be a security risk, or at the least slow and ambiguous if you have more than one app with the same name.

If you enter the entire path to your application, like I've suggested above, then your OS knows exactly where to find the application and will run it directly without searching through the directories in your PATH.

You can add new directories to your PATH and you can add an alias to an application to one of the PATH directories. Then you would be able to just type "pear" and the OS could find it. There are tutorials for adding directories to your PATH all over the internet.

The locate database needs to be created in order to use the locate command. This is a separate issue. You can build the locate database and it will look over all of your files. It will take a little while to run, but when it's done the locate command will work. However, since you already know where your pear app is, locate won't give you any new information.

like image 37
Scott Saunders Avatar answered Sep 17 '22 02:09

Scott Saunders