Mac – How to install PHP, Pear, PECL, and APC with Homebrew on Mac OS X

homebrewmacpeclPHPphp-apc

I'm trying to install APC for PHP 5.3 in the easiest way possible. I love Homebrew so I started down that route. I was able to install PHP 5.3.6 with this command:

brew install https://github.com/adamv/homebrew-alt/raw/master/duplicates/php.rb --with-mysql

I think this is supposed to install PHP, Pear, and PECL. It seems to install these just fine.

Now when I try to install APC:

$ pecl install apc
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes

Warning: require_once(Archive/Tar.php): failed to open stream: No such file or directory in PackageFile.php on line 305

Warning: require_once(Archive/Tar.php): failed to open stream: No such file or directory in /usr/local/Cellar/php/5.3.6/lib/php/PEAR/PackageFile.php on line 305

Fatal error: require_once(): Failed opening required 'Archive/Tar.php' (include_path='/usr/local/Cellar/php/5.3.6/lib/php') in /usr/local/Cellar/php/5.3.6/lib/php/PEAR/PackageFile.php on line 305

How can I fix this?

Best Answer

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:

  1. Reinstall PHP via: brew install php.
  2. 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.

Related Question