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?
Macos – How to install PHP PECL extensions with Macports
macosmacportspeclPHP
Related Solutions
Now homebrew-php
has been migrated to homebrew-core
and by default, PECL should be installed along with your PHP.
Here are the suggested steps:
- Reinstall PHP via:
brew install php
. - Check
pecl
command by:which -a pecl
.
To see which files were installed, see: brew list php
.
To install PHP extensions, you need to use PECL as a recommended way.
With the migration to Homebrew-core the php formula has stopped taking over the role of PECL. Installing xdebug can (and should) be done through PECL. Source: GH-26007
For example: pecl install apc
or pecl install xdebug
.
If you've got some problem installing the extension, you need to report it to its maintainer. Check PECL website for more details.
Macports packages several versions of PosgreSQL where each version's packages' names contain the version string. So if XY is the concatenation of major and minor PostgreSQL release version (from 8.1 through 9.4 beta as of this writing), the packages are named like this:
- postgresqlXY (This installs the client, 'psql'.)
- postgresqlXY-server (This is the server portion.)
- postgresqlXY-doc (And so on.)
You simply need to activate the installed version of your choice. If you install the package "postgresqlXY" (any version), you also get the package "postgresql_select" as a dependency, which lets you query the active version of postgresql:
$ port select --list postgresql
Available versions for postgresql:
none (active)
postgresqlXY
You can specify the active version like this:
$ port select --set postgresql postgresqlXY
Selecting 'postgresqlXY' for 'postgresql' succeeded. 'postgresqlXY' is now active.
That causes Macports to place a symlink from /opt/local/bin/psql (which is on the path because you installed Macports) to the binary installed at /opt/local/lib/postgresqlXY/bin/psql (which isn't on the path):
$ which psql # That created this symlink to the active version:
/opt/local/bin/psql
Note that you can always access version X.Y of the client binary via /opt/local/bin/psqlXY, which is another symlink Macports maintains for each installed version no matter what is or isn't selected. It was there before you selected version XY, and likewise remains if you select "none" to remove the standard binary name from your path:
$ port select postgresql none
Selecting 'none' for 'postgresql' succeeded. 'none' is now active.
$ which psql # Not on the path because 'none' is active!
$ which psqlXY # But this is always present:
/opt/local/bin/psqlXY
People end up needing ready access to multiple versions of various pieces of software, and Macports makes that easy by packaging multiple versions of about 50 popular examples using this selection mechanism and corresponding somesoftware_select package as dependency. View the list:
$ port search _select
Best Answer
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 simpleln -s /opt/local/lib/php/pear/bin/pear /opt/local/bin/pear
and arehash
(that bit might be a tcsh-ism), and I was in business.