I’m using homebrew to install PHP on macOS 12.4 (Monterey), and having difficulty getting the suggested PECL extension install method to work. I’ve installed php 7.4 on macOS:
brew install [email protected]
And then I ran the following
pecl install command to install a PHP extension, as an example:
pecl install bz2
I get the following failure:
WARNING: "pear/bz2" is deprecated in favor of "channel://http://php.net/bzip2/ext/bz2" downloading bz2-1.0.tgz ... Starting to download bz2-1.0.tgz (7,168 bytes) .....done: 7,168 bytes 3 source files, building running: phpize Cannot find config.m4. Make sure that you run '/opt/homebrew/opt/[email protected]/bin/phpize' in the top level source directory of the module ERROR: `phpize' failed
I read some other posts mentioning that
pecl install might be broken now and that the packages need to be downloaded, built, and installed in separate steps. I then tried to perform a build of the binaries from the downloaded source by running the following:
pecl download bz2 pecl bundle bz2 cd bz2 pecl build
I get a build failure ending with the following log:
... checking for PHP prefix... /opt/homebrew/Cellar/[email protected]/7.4.29 checking for PHP includes... -I/opt/homebrew/Cellar/[email protected]/7.4.29/include/php -I/opt/homebrew/Cellar/[email protected]/7.4.29/include/php/main -I/opt/homebrew/Cellar/[email protected]/7.4.29/include/php/TSRM -I/opt/homebrew/Cellar/[email protected]/7.4.29/include/php/Zend -I/opt/homebrew/Cellar/[email protected]/7.4.29/include/php/ext -I/opt/homebrew/Cellar/[email protected]/7.4.29/include/php/ext/date/lib checking for PHP extension directory... /opt/homebrew/Cellar/[email protected]/7.4.29/pecl/20190902 checking for PHP installed headers prefix... /opt/homebrew/Cellar/[email protected]/7.4.29/include/php checking if debug is enabled... no checking if zts is enabled... no checking for gawk... no checking for nawk... no checking for awk... awk checking if awk is broken... no checking for BZip2 support... yes, shared checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution `/opt/homebrew/lib/php/pecl/20190902/bz2/configure --with-php-config=/opt/homebrew/opt/[email protected]/bin/php-config' failed
I tried to install BZip2 using
brew install BZip2, verified installation and PATH registration for the package, restarted the terminal, and got the same error.
The bz2 extension is just one example but I haven’t been able to get any of the pecl bundles to install or build successfully.
I’m wondering if anyone has had success building and installing PHP 7.4+ extensions on macOS 12+, and if so, what was your method to get these packages to properly build on this setup?