Installing the MongoDB PHP Driver on OSX with Homebrew
If you are using » Homebrew, the PHP tap includes formulae for installing the driver on various PHP versions.
- php54-mongodb
- php55-mongodb
- php56-mongodb
- php70-mongodb
For example, you might install the driver for PHP 7.0 using the following command:
1 | brew install php70-mongodb |
You must first tap the PHP formula repository from terminal like so
brew tap homebrew/php
in order to install PHP extensions like MongoDB via Homebrew.After tapping the formula repository, install the MongoDB extension
1 brew install phpxx-mongodbwhere xx is the version number.
No only just you install it via brew for correct version of php installed on your machine.You have to set extension in php.ini too.
In case of macOS and php 5.6 installed.
I have to set
1 extension="/usr/local/opt/php56-mongo/mongo.so"The correct path will show mongodb loaded on phpinfo.
The correct command for installation is using homebrew is
1 brew install homebrew/php/phpxx-mongodbForex. to install the driver for php5.6 use :
1 brew install homebrew/php/php56-mongodb