dongtiao0279
2016-06-21 13:18
浏览 68
已采纳

使用PHP7和Symfony3的MongoDB

I have a problem with MongoDB. I want install MongoDBBundle in my Symfony App but composer return an error:

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


 Problem 2
- doctrine/mongodb-odm 1.1.0 requires doctrine/mongodb ~1.3 -> satisfiable by doctrine/mongodb[1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.0 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.1 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.2 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.3 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.4 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.5 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb-odm 1.0.6 requires doctrine/mongodb ~1.2 -> satisfiable by doctrine/mongodb[1.2.x-dev, 1.3.x-dev, 1.4.x-dev].
- doctrine/mongodb 1.3.x-dev requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.2.x-dev requires ext-mongo ^1.2.12 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.4.x-dev requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system.
- Installation request for doctrine/mongodb-odm ~1.0 -> satisfiable by doctrine/mongodb-odm[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4, 1.0.5, 1.0.6, 1.1.0].
To enable extensions, verify that they are enabled in those .ini files:
- /etc/php/7.0/cli/php.ini
- /etc/php/7.0/cli/conf.d/10-mysqlnd.ini
- /etc/php/7.0/cli/conf.d/10-opcache.ini
- /etc/php/7.0/cli/conf.d/10-pdo.ini
- /etc/php/7.0/cli/conf.d/15-xml.ini
- /etc/php/7.0/cli/conf.d/20-apcu.ini
- /etc/php/7.0/cli/conf.d/20-apcu_bc.ini
- /etc/php/7.0/cli/conf.d/20-calendar.ini
- /etc/php/7.0/cli/conf.d/20-ctype.ini
- /etc/php/7.0/cli/conf.d/20-curl.ini
- /etc/php/7.0/cli/conf.d/20-dom.ini
- /etc/php/7.0/cli/conf.d/20-exif.ini
- /etc/php/7.0/cli/conf.d/20-fileinfo.ini
- /etc/php/7.0/cli/conf.d/20-ftp.ini
- /etc/php/7.0/cli/conf.d/20-gettext.ini
- /etc/php/7.0/cli/conf.d/20-iconv.ini
- /etc/php/7.0/cli/conf.d/20-intl.ini
- /etc/php/7.0/cli/conf.d/20-json.ini
- /etc/php/7.0/cli/conf.d/20-mcrypt.ini
- /etc/php/7.0/cli/conf.d/20-mongodb.ini
- /etc/php/7.0/cli/conf.d/20-mysqli.ini
- /etc/php/7.0/cli/conf.d/20-pdo_mysql.ini
- /etc/php/7.0/cli/conf.d/20-phar.ini
- /etc/php/7.0/cli/conf.d/20-posix.ini
- /etc/php/7.0/cli/conf.d/20-readline.ini
- /etc/php/7.0/cli/conf.d/20-shmop.ini
- /etc/php/7.0/cli/conf.d/20-simplexml.ini
- /etc/php/7.0/cli/conf.d/20-sockets.ini
- /etc/php/7.0/cli/conf.d/20-sysvmsg.ini
- /etc/php/7.0/cli/conf.d/20-sysvsem.ini
- /etc/php/7.0/cli/conf.d/20-sysvshm.ini
- /etc/php/7.0/cli/conf.d/20-tokenizer.ini
- /etc/php/7.0/cli/conf.d/20-wddx.ini
- /etc/php/7.0/cli/conf.d/20-xdebug.ini
- /etc/php/7.0/cli/conf.d/20-xmlreader.ini
- /etc/php/7.0/cli/conf.d/20-xmlwriter.ini
- /etc/php/7.0/cli/conf.d/20-xsl.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

I don't understand this error because the extension MongoDB not missing. I have installed this extension with this command: pecl install mongodb

and when i list the php module load with php -m:

[PHP Modules]
apc
apcu
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gettext
hash
iconv
intl
json
libxml
mcrypt
mongodb
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
Phar
posix
readline
Reflection
session
shmop
SimpleXML
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xdebug
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zlib

I try this solution:

echo "extension=mongodb.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`

But it is not the solution.

Thank you for your help.

Thibault.

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • duanao3204 2016-06-21 13:44
    已采纳
    doctrine/mongodb 1.4.x-dev requires ext-mongo ^1.5
    

    ext-mongo is the legacy MongoDB driver (\MongoClient). ext-mongo was never ported to Zend 3 (PHP7). The new Mongo driver that does work under PHP7 (the one you installed via PECL) is ext-mongodb. This is not supported by the Doctrine driver for MongoDB.

    You have two choices: find a Doctrine driver that does work with the newer Mongo extension, or downgrade to PHP 5.6 and install ext-mongo.

    There is a currently open issue on support for the new extension.

    已采纳该答案
    打赏 评论
  • drze7794 2016-06-21 13:29

    Is the line extension=mongo.so In your CLI php.ini file, and uncommented? Might be worthwhile to check ALL your php.ini files. This issue apparently came up with Symfony 2 as well: Can't install mongodb doctrine in symfony2 with composer

    打赏 评论
  • dqed19166 2016-06-21 14:25

    Ok i understand. For downgrade to PHP 5.6 the steps is: apt-get remove php7.0. apt-get install php5.6. The require for composer.json is okay ?

    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.1.*",
        "doctrine/orm": "^2.5",
        "doctrine/doctrine-bundle": "^1.6",
        "doctrine/doctrine-cache-bundle": "^1.2",
        "symfony/swiftmailer-bundle": "^2.3",
        "symfony/monolog-bundle": "^2.8",
        "symfony/polyfill-apcu": "^1.0",
        "sensio/distribution-bundle": "^5.0",
        "sensio/framework-extra-bundle": "^3.0.2",
        "incenteev/composer-parameter-handler": "^2.0",
        "friendsofsymfony/user-bundle": "2.0.x-dev",
        "mongodb/mongodb": "dev-master",
        "alcaeus/mongo-php-adapter": "dev-composer-replace",
        "doctrine/mongodb": "1.4.x-dev",
        "doctrine/mongodb-odm": "~1.0",
        "doctrine/mongodb-odm-bundle": "~3.0"
    },
    
    打赏 评论

相关推荐 更多相似问题