I have PHP5 installed via macports in /opt/local/..the default location for macports. There's no portfile for pear. If I do a standard pear install from the pear site what directory location should pear be placed in to work with PHP?
问题:
回答1:
While the curl option works, it won't update as you update your ports. An alternative:
sudo port install php5 +pear
This will install the variant of php5 with pear, in the same location as downloading above, and it will update as you update macports.
回答2:
I had a similar issue just now, and went for installing PEAR in exactly the directory you mentioned.
curl -O http://pear.php.net/go-pear.phar
sudo php go-pear.phar
I changed the installation base directory ($prefix) to point to /opt/local and ran the installer. It amended my php.ini file to include the PEAR path.
My bash path already contained /opt/local/bin, so PEAR just worked!
回答3:
I wonder why nobody wrote an updated solution, so I do it:
sudo port install pear-PEAR
sudo port install php53-pear
Replace 53
with whatever version of PHP you want to use. Then install the pear-package you need with MacPorts! You can get a full list of available packages with
port echo name:^pear-
As mentioned in a comment of the other answer, go here for more info: https://superuser.com/q/650299/39309
回答4:
For those of you running PHP outside of MacPorts @Ben's answer, with the following modification, is actually the solution to the problem. I needed PEAR to install PHPUnit so I could do some unit testing but I use XAMPP.
I followed Ben's solution but got an error when trying to install it. My error was:
WARNING! The include_path defined in the currently used php.ini does
not contain the PEAR PHP directory you just specified:
</opt/local/share/pear>
If the specified directory is also not in the include_path used by
your scripts, you will have problems getting any PEAR packages working.
Current include path : .:
Configured directory : /opt/local/share/pear
Currently used php.ini (guess) :
I set the path of Currently used php.ini to the following and all worked perfectly:
/Applications/XAMPP/xamppfiles/etc/php.ini
Hope that at worst, this helps other XAMPP users!