[英]PHP 7 with Doctrine MongoDB ODM
I have a Symfony 2 application that is using Doctrine MongoDB ODM and I'm trying to get this running with PHP 7. 我有一个使用Doctrine MongoDB ODM的Symfony 2应用程序,我正在尝试使用PHP 7运行它。
I have installed PHP 7 successfully but installing dependencies through Composer is giving me grief with the following error: 我已经成功安装了PHP 7,但是通过Composer安装依赖项让我感到悲伤,出现以下错误:
doctrine/mongodb 1.0.x-dev requires ext-mongo >=1.2.12,<1.7-dev -> the requested PHP extension mongo is missing from your system.
I managed to install the PHP 7 mongo extension through apt: 我设法通过apt安装PHP 7 mongo扩展:
apt-get install php7.0-mongo
Just to be sure, I have also installed the mongodb
extension through PECL: 为了确定,我还通过PECL安装了
mongodb
扩展:
sudo apt-get install -y php-pear php7.0-dev libcurl3-openssl-dev
sudo pecl install mongodb
However, I'm still get the error that the mongo extension cannot be found. 但是,我仍然得到无法找到mongo扩展名的错误。 There seems to be a version discrepancy in that
ext-mongo >=1.2.12
is required but only 1.1.6
was installed:: 似乎存在版本差异,因为
ext-mongo >=1.2.12
是必需的,但只安装了1.1.6
::
$ php -i | grep mongo
/etc/php/7.0/cli/conf.d/20-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 is the correct way to install the mongo extension required by Doctrine ODM for PHP 7? 安装Doctrine ODM for PHP 7所需的mongo扩展的正确方法是什么?
On PHP7 you cannot install mongo
extension. 在PHP7上,您无法安装
mongo
扩展。 What you can do, is to install https://github.com/alcaeus/mongo-php-adapter first, then install doctrine. 您可以做的是首先安装https://github.com/alcaeus/mongo-php-adapter ,然后安装doctrine。
composer require alcaeus/mongo-php-adapter
in composer.json I added 在composer.json中我添加了
"provide" : {
"ext-mongo": "*"
},
before "require" and this forces to install latest extension 在“require”之前,这将强制安装最新的扩展
In order to use Symfony with MongoDB you need: 要将Symfony与MongoDB一起使用,您需要:
You can follow the instructions here: "How to install Symfony3 with MongoDB" 您可以按照此处的说明操作: “如何使用MongoDB安装Symfony3”
It was written for Symfony3 but for Symfony2 is the same issue. 它是为Symfony3编写的,但对Symfony2来说也是同样的问题。 The problem was PHP7 + mongodb driver + Doctrine.
问题是PHP7 + mongodb驱动程序+ Doctrine。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.