Instalación manual del Controlador de MongoDB para PHP

Para los desarrolladores de controladores y gente interesada en las últimas correcciones de errores, se puede compilar el controlador desde el último código fuente en » Github. Ejecute los siguientes comandos para clonar y construir el proyecto:

$ git clone https://github.com/mongodb/mongo-php-driver.git
$ cd mongo-php-driver
$ git submodule update --init
$ phpize
$ ./configure
$ make all
$ sudo make install

El último paso informará sobre dónde ha sido instalado mongodb.so, similar a:

Installing shared extensions:     /usr/lib/php/extensions/debug-non-zts-20151012/

Asegúreser de que la opción extension_dir de php.ini apunta al directorio donde se instaló mongodb.so. Se puede verificar la opción ejecutando:

$ php -i | grep extension_dir
  extension_dir => /usr/lib/php/extensions/debug-non-zts-20151012 =>
                   /usr/lib/php/extensions/debug-non-zts-20151012

Si los directorios difieren, cambie extension_dir de php.ini o mueva manualmente mongodb.so al directorio correcto.

Añada la siguiente línea al fichero php.ini:

extension=mongodb.so

add a note add a note

User Contributed Notes 3 notes

up
24
chatocoral at gmail dot com
6 years ago
You think this is to complicated? You use Ubuntu 14 or 16? use this:

sudo apt-get install php-mongodb

This installs everything you need to use MongoDB inside PHP.

Don't stop using MongoDB, is the best that will happen to you.

You're Welcome.
up
1
fgm at osinet dot fr
7 years ago
a) If your git version is not recent enough, as can happen e.g. on Ubuntu 12.04 LTS, git submodule --init won't exist
In that case use:

    git submodule init
    git submodule update

b) make install does not create a mongodb.conf configuration file to support the debian/ubuntu PHP versions phpenmod/phpdismod commands. To have them work:

- do not add the extension=mongodb.so line to php.ini
- add it to a mongodb.ini file in the PHP mods-available directory
- the commands will then work for this extension

c) if you have multiple versions of PHP on a system such as b), the phpenmod/phpdismod commands may fail if the extension is not built for the default PHP CLI version. To have it be enabled for a specific version, use the -v argument, like

    phpenmod -v php7.1 mongodb
up
-1
Anisur Rahman (anisur2805 at gmail dot com)
3 years ago
After installing mongodb, in terminal there are couple of error ex.

PHP Warning:  PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: C:\xampp\php\ext\mongodb.so (The specified module could not be found.), C:\xampp\php\ext\php_mongodb.so.dll (The specified module could not be found.)) in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'mongodb.so' (tried: C:\xampp\php\ext\mongodb.so (The specified module could not be found.), C:\xampp\php\ext\php_mongodb.so.dll (The specified module could not be found.)) in Unknown on line 0

https://prnt.sc/ubr5mq

Solution:
1. If you include mongodb extension in php.ini file first remove that
2. Goto your php path inside Xampp and create an file called mongodb.ini and pest this below line, see ss - https://prnt.sc/ubr7ii
code extension=mongodb.so

This solution works in windows 10, php 7.4 version
To Top