&reftitle.install;
Installing the MongoDB PHP Driver with PECL
&pecl.info;
&url.pecl.package;mongodb
Linux, Unix, and OS X users may run the following command to install the
driver:
Add the following line to your &php.ini; file:
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-mongodbphp55-mongodbphp56-mongodbphp70-mongodb
For example, you might install the driver for PHP 7.0 using the following
command:
Installing the MongoDB PHP Driver on Windows
Precompiled binaries for each release are available from
PECL for a variety of
combinations of versions, thread safety, and VC libraries. Extract the
archive and put php_mongo.dll in your PHP extension
directory ("ext" by default).
Add the following line to your &php.ini; file:
Manually Installing the MongoDB PHP Driver
For driver developers and people interested in the latest bugfixes, you can
compile the driver from the latest source code on
Github. Run the following
commands to clone and build the project:
The last step will report where mongodb.so has been
installed, similar to:
Ensure that the extension_dir option
in &php.ini; points to the directory where mongodb.so
was installed. You can query the option by running:
/usr/lib/php/extensions/debug-non-zts-20151012 =>
/usr/lib/php/extensions/debug-non-zts-20151012
]]>
If the directories differ, either change
extension_dir in &php.ini; or
manually move mongodb.so to the correct directory.
Add the following line to your &php.ini; file:
Manually Installing the MongoDB HHVM Driver
At the time of this writing, HHVM does not have a package manager for
extensions. Download the latest driver from
GitHub. Alternatively,
you may clone the repository to build the latest source code:
Generate the configure files for the bundled libraries. For this
this to work, you need to have the automake,
autoconf, and libtool packages installed (e.g.
through apt-get).
Build and install the driver by running:
If the hphpize command is not available, you will need to
either compile HHVM from source or install the hhvm-dev package
(e.g. through apt-get).
The last step will report where mongodb.so has been
installed, similar to:
Add the following line to your &php.ini; file (usually found in "/etc/hhvm"):