10

I try to install doctrine/mongodb-odm[1.0.5] over composer but drops me

  Problem 1
    - doctrine/mongodb 1.3.0 requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.2.2 requires ext-mongo ^1.2.12 -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.2.1 requires ext-mongo ^1.2.12 -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.2.0 requires ext-mongo ^1.2.12 -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb-odm 1.0.5 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.0, 1.2.1, 1.2.2, 1.3.0].
    - Installation request for doctrine/mongodb-odm ~1.0.5 -> satisfiable by doctrine/mongodb-odm[1.0.5].

mongo extension is already installed

php -i | grep mongo

/usr/local/etc/php/7.0/conf.d/ext-mongodb.ini
mongodb
mongodb support => enabled
mongodb version => 1.1.6
mongodb stability => stable
libmongoc version => 1.3.5
mongodb.debug => no value => no value

what went wrong in this case?

deroccha
  • 1,181
  • 4
  • 22
  • 41

3 Answers3

34

On PHP7 you have mongodb extension as @xaben mentioned. You can use this with doctrine until it support mongodb but by installing additional library https://github.com/alcaeus/mongo-php-adapter

First install via composer:

composer require alcaeus/mongo-php-adapter

and later install doctrine. It's works very well in my case.

malcolm
  • 5,486
  • 26
  • 45
  • 2
    This solution is also recommended in official release notes http://www.doctrine-project.org/2016/02/16/doctrine-mongodb-odm-release-1.0.5.html – edigu Dec 02 '16 at 19:50
  • Works beautifully on PHP 7.1 using Symfony 3.2 and Doctrine ODM 1.1 – Samir Patel Jan 02 '17 at 14:45
  • "and later install doctrine", I would say: "and later install `doctrine/mongodb-odm`". – Kwadz Jan 24 '17 at 16:03
  • @Kwadz I would say: "everyone who read this topic exactly knows which Doctrine package cause the problem, it's not odm, dbal or phpcr. Even you have package name in the question title". – malcolm Jan 24 '17 at 20:21
  • @malcolm You comment "everyone who read this topic exactly knows which Doctrine package cause the problem", nobody can be sure about that, please don't forget beginners. You comment: "it's not odm, dbal or phpcr.", if it's not odm, what do you mean by doctrine? I guess you wanted to write orm instead of odm... In all cases I suggest you to edit your answer with the correct package name. – Kwadz Jan 24 '17 at 21:42
  • @Kwadz I suggest you to answer some questions instead of searching non existed problems. Probably you found this topic because you have the same issue with php7 and new mongodb driver. It's the same like: "Do you have a car? Yes I do." Why someone must add a car to the answer? You are new english grammar pionner or what... – malcolm Jan 25 '17 at 01:03
  • @malcom Relax, I just suggested a little improvement in spelling to help beginners, nothing against you or your answer which is good. – Kwadz Jan 25 '17 at 09:39
  • 1
    You save a lot of my time. Thank you! – Daniel May 15 '17 at 19:27
  • 1
    Excellent answer, Invest lots of time. Then try this answer and finally things work. Thanks!! – AnkitJ Jul 06 '17 at 09:54
6

PHP has 2 extensions for MongoDB:

  1. The legacy one found at http://php.net/manual/en/book.mongo.php
  2. The current one http://php.net/manual/en/set.mongodb.php

In case of "doctrine/mongodb-odm" it expects to find the legacy one "mongo" but what you have installed is the newer one "mongodb".

In order to use the legacy extension you need to use php <= 5.6, for php 7 only mongodb is available.

xaben
  • 69
  • 1
0

I had the problem , but install and config symfony 3.1 with php 5.6 and mysql , After need installer mongodb, so udpate 7.1

problem composer.json :

"config": {
    "platform": {"php": "5.6"}
}

Change:

"config": {
    "platform": {"php": "7.1"}
}
maccevedor
  • 155
  • 2
  • 5