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:

$ brew install php70-mongodb

Коментарии

The correct command for installation is using homebrew is 
brew install homebrew/php/phpxx-mongodb

For ex. to install the driver for php5.6 use :
brew install homebrew/php/php55-mongodb
2016-09-03 13:07:56
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
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

    brew install phpxx-mongodb

where xx is the version number.
2016-09-04 00:05:25
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
Below command work for me mac sierra os
brew install php55-mongodb
2016-11-24 08:06:29
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
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 

extension="/usr/local/opt/php56-mongo/mongo.so"

The correct path will show mongodb loaded on phpinfo.
2017-03-02 16:29:41
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
The mongodb extension is also available for PHP 7.1, you can install it using similar command:

brew install php71-mongodb
2017-04-12 11:56:41
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
For OS Sierra 10.12.6 

PHP 5.6 

brew tap homebrew/php
brew install php56-mongodb 
extension="/usr/local/opt/php56-mongodb/mongodb.so"
2017-09-23 05:24:54
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
Автор:
Then I try install 

brew install php72-mongodb

I get error:

Error: No available formula with the name "php72-mongodb" 
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching for similarly named formulae...
==> Searching local taps...
Error: No similarly named formulae found.
==> Searching taps...
==> Searching taps on GitHub...
2018-04-04 20:42:11
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
All formulas in homebrew/php has been deleted or moved to homebrew/core.

To avoid installation problem in homebrew, you can use the command below:

brew tap kyslik/php
brew install phpXX-mongodb
2018-04-05 10:57:18
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
The mongodb install has been removed from Homebrew. To install the mongodb extension you need to use pecl.

sudo pecl install mongodb

You may need to follow some additional configuration. Follow the inline instructions as they appear. Once the install is finished it will add two lines at the bottom of your php.ini file. Instead, remove these lines and add the and add a separate file to your conf.d directory in the same directory as you php.ini file.

In php.ini remove

extension="mongodb.so" // remove
extension="php_mongodb.so // remove 

Then run:

$ touch /usr/local/etc/php/5.6/conf.d/ext-mongodb.ini

Finally add this line to the new file:

// example
extension="/usr/local/Cellar/php@5.6/5.6.35/pecl/20131226/mongodb.so"
2018-04-09 00:21:41
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html
Автор:
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.
2018-12-18 19:29:58
http://php5.kiev.ua/manual/ru/mongodb.installation.homebrew.html

    Поддержать сайт на родительском проекте КГБ