I'm using PHP 5.5 installed through Macports. I'd like to add the APCu PECL library. But there's no macports package and I can't see a way to install the PEAR/PECL command line utility. So how does one add APCu (or really any PECL library) to PHP 5.5 installed via Macports?
Asked
Active
Viewed 1.3k times
4
-
PECL is PHP's own package manager, so you wouldn't find a Macports package for APCu; you'd instead find a PECL package for it. Consider [this Stack Overflow answer](http://stackoverflow.com/a/5808633/1713079) with regard to ensuring that you have Pear installed (if `sudo pear` at the command line does anything, then you already have it), and then try `sudo pear search apcu` or `sudo pear search APCu` to find the Pear package you want to install. – Aaron Miller Sep 26 '13 at 15:02
-
Thanks, Aaron. php55 on macports doesn't have a pear variant like the older versions did. And there's no package for adding the pear command. Other PECL packages like memcached are in macports as php55-memcached, but not apcu. – Matt S Sep 26 '13 at 15:48
-
In that case, you may need to build from source, which requires not only the library source, but also the PHP source; you can probably get that from Macports, but I wouldn't begin to know how. – Aaron Miller Sep 26 '13 at 15:52
-
Yeah I was hoping to avoid that as a last resort. – Matt S Sep 26 '13 at 15:55
3 Answers
5
I was stumbling over how to get PEAR working on MacPorts as well. It turns out that I installed it somehow (possibly with the core PHP package, php54 with the default variants in my case…?), but MacPorts didn't put the binary in a normal $PATH location, so my shell couldn't find it. It was hanging out in /opt/local/lib/php/pear/bin/pear. A simple ln -s /opt/local/lib/php/pear/bin/pear /opt/local/bin/pear and a rehash (that bit might be a tcsh-ism), and I was in business.
Garrett Albright
- 175
- 5
-
Ah I see it! So is that version of pear safe to run with php55 even though it's under the older php lib dir? I guess they just have to share the pear output dir using the php55-pear package. – Matt S Sep 26 '13 at 16:37
-
"Safe" in what sense? I don't use PEAR for much outside of installing [Drush](https://github.com/drush-ops/drush), but I haven't had any problems with it once I figured out how to get it working as above. I also don't think it's an "older" directory since I found it on a new machine which never had an older PHP package installed on it (not counting stuff packaged with OS X, but those things are never under `/opt` AFAIK). – Garrett Albright Sep 26 '13 at 17:43
-
1This worked for me with PEAR, but PECL is failing. It's trying to compile against the PHP dev headers from OSX, not the ones from Macports. So the binary is there but it has to be reconfigured manually. – Matt S Oct 02 '13 at 17:35
-
Not familiar with PECL, so I can't help you there, but I'll add that if you're installing PECL with Macports, I find it odd it would try to compile against OS X's stuff instead of it's own. – Garrett Albright Oct 02 '13 at 17:46
1
From the mac terminal console, run:
$ port search pear | grep php54
php54-pear @20110901_4 (php, www)
Optional port adds the PEAR repository to the include path for php54.
There is a pear package for 5.4 now. You can then:
$ sudo port install php54-pear
And you should be in good shape.
TrippyD
- 111
- 2
-
Can you explain how to get to this point? Not necessarily for the OP, but for others who hit this page from search engines and don't know? – Canadian Luke Nov 25 '13 at 19:33
-
-3
You can try Homebrew instead, e.g.
brew install php56 --with-pear
Then pecl command should be already there, if not, link it again via:
brew unlink php56 && brew link php56 --dry-run && brew link php56
or manually:
ln -vs "$(find /usr/local/Cellar/php56 -name pecl -print -quit)" /usr/local/bin
kenorb
- 24,736
- 27
- 129
- 199
-
CYS on that, MacPorts has some pretty recent packages by my read. – cwallenpoole Apr 23 '18 at 20:31