How do you install PHP PECL extensions with Macports?

13,069

Solution 1

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.

Solution 2

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.

Share:
13,069

Related videos on Youtube

Matt S
Author by

Matt S

Managing development teams and writing software for 20+ years. Owner of SocialSentiment.io. On LinkedIn / Github / Twitter.

Updated on September 18, 2022

Comments

  • Matt S
    Matt S over 1 year

    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?

    • Aaron Miller
      Aaron Miller over 10 years
      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 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.
    • Matt S
      Matt S over 10 years
      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.
    • Aaron Miller
      Aaron Miller over 10 years
      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.
    • Matt S
      Matt S over 10 years
      Yeah I was hoping to avoid that as a last resort.
  • Matt S
    Matt S over 10 years
    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.
  • Garrett Albright
    Garrett Albright over 10 years
    "Safe" in what sense? I don't use PEAR for much outside of installing 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
    Garrett Albright over 10 years
    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.
  • TrippyD
    TrippyD over 10 years
    Edited for clarification. Thx Luke.
  • cwallenpoole
    cwallenpoole about 6 years
    CYS on that, MacPorts has some pretty recent packages by my read.