Homebrew 1.5.0 deprecated the » Homebrew/php tap and removed formulae for individual PHP extensions. Going forward, macOS users are advised to install the » php formula and follow the standard PECL installation instructions using the pecl command provided by the Homebrew PHP installation.
How to install on macOS Mojave
Start with:
sudo pecl install mongodb
To check if mongodb package is installed, look for “mongodb” when you run:
pecl list
To get your installed mongodb.so path, run:
pecl list-files mongodb | grep mongodb.so
then remove (or comment out) on your php.ini file:
extension="mongodb.so"
(I could not found a line with extension=”php_mongodb.so”)
now insert a line with:
extension="{{the path to your installed mongodb.so}}"
Run this command to get your ext-*.ini directory path:
php -i | grep Scan
Create your ext-mongodb.ini with:
touch {{your conf.d path}}/ext-mongodb.ini
like:
touch /usr/local/etc/php/7.1/conf.d/ext-mongodb.ini
Restart your apache to read the new configuration
Sanity check with:
php -i | grep mongodb
Your’re ready to go.