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

使用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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀