Doctrine MongoDB

1

I'm trying to install the Doctrine ODM for MongoDB through Composer and I get the very famous error that I'm missing the mongo extension for php

  

Problem 1
      - Installation request for doctrine / mongodb 1.4.0 - > satisfiable by doctrine / mongodb [1.4.0].
      - doctrine / mongodb 1.4.0 requires ext-mongo ^ 1.5 - > the requested PHP extension mongo is missing from your system.

By doing a phpinfo (); I see that the extension is loaded correctly.

    
asked by Infobuscador 14.03.2017 в 21:23
source

1 answer

0

Apparently Doctrine and many of the libraries that I have tried use the methods of mongo.so and therefore when loading mongodb.so, it does not work.

The methods change from one extension to another as can be seen below:

  

MongoClient () becomes \ MongoDB \ Client ()
   MongoCollection () becomes \ MongoDB \ Collection ()

To install the old package: sudo pecl install mongo instead of sudo pecl install mongodb

It is also important to integrate mongo.so within the php.ini that corresponds to the CLI: /etc/php5/cli/php.ini

Another thing that happened to me and that I did not realize was that I set up a BOX from Vagrant in which I installed LAMP and MongoDB. That box had it synchronized with the IDE folder to see the changes it made. When I needed to install a library, I went to the PhpStorm terminal in the path that synchronized folder and executed "Composer update" but without realizing that the dependencies search was going to do based on the configuration of my Local PHP and not the Virtual Box.

    
answered by 15.03.2017 в 23:46