简体   繁体   English

无法使用composer在symfony2中安装mongodb doctrine

[英]Can't install mongodb doctrine in symfony2 with composer

I've followed the official documentation 我按照官方文档

when I run composer update I have this error : Your requirements could not be resolved to an installable set of packages. 当我运行composer update时出现此错误:您的要求无法解析为可安装的软件包集。

  Problem 1
    - doctrine/mongodb 1.0.4 requires ext-mongo >=1.2.12,<1.6-dev -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.0.3 requires ext-mongo >=1.2.12,<1.5-dev -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.0.2 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.0.1 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb 1.0.0 requires ext-mongo >=1.2.12,<1.4-dev -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb-odm 1.0.0-BETA9 requires doctrine/mongodb 1.0.* -> satisfiable by doctrine/mongodb[1.0.0, 1.0.1, 1.0.2, 1.0.3, 1.0.4].
    - Installation request for doctrine/mongodb-odm 1.0.0-BETA9 -> satisfiable by doctrine/mongodb-odm[1.0.0-BETA9].

When I run php -m I can't find mongo extension , but the server is running and I can use Mongo in PHP, does anyone know what should the problem be ? 当我运行php -m我找不到mongo扩展,但服务器正在运行,我可以在PHP中使用Mongo,有谁知道问题应该是什么? I doubt that the doctrine can't find the mongo extension.. thanks ! 我怀疑这个学说找不到mongo扩展..谢谢!

I fixed it ! 我修好了它 ! As expected, it was because of the extension so here are the steps to take if you face the same problem as me : the requested PHP extension mongo is missing from your system. 正如预期的那样,这是因为扩展所以如果你遇到与我相同的问题,这里是采取的步骤: the requested PHP extension mongo is missing from your system.

  1. run the command : php --ini , you will see all the configuration files parsed! 运行命令: php --ini ,您将看到解析的所有配置文件! For me , I am using PHP-fpm , I thought the only php.ini file needed was inside fpm folder, but I was wrong there was a php.ini file inside CLI folder and it's this folder that tells the server which modules are loaded , and it's exactly the same file that doctrine reads the extensions from. 对我来说,我使用PHP-fpm,我认为所需的唯一php.ini文件是在fpm文件夹中,但我错了在CLI文件夹中有一个php.ini文件,它是这个文件夹告诉服务器哪些模块被加载,它与doctrine读取扩展名的文件完全相同。
  2. Open CLI/php.ini and add this line in the end extension=mongo.so . 打开CLI / php.ini并在end extension=mongo.so添加此行。
  3. Restart PHP : service php5-fpm restart 重启PHP: service php5-fpm restart

That's it! 而已!

for OSX: 对于OSX:

brew install php56-mongo

if it errors out: read the error message carefully and follow it to rerun the command. 如果错误输出:仔细阅读错误消息并按照它重新运行命令。

source: 资源:

http://php.net/manual/en/mongo.installation.php#mongo.installation.osx http://php.net/manual/en/mongo.installation.php#mongo.installation.osx

Linux Linux的

To install PHP's MongoDB extension, run: 要安装PHP的MongoDB扩展,请运行:

sudo apt-get install php-mongo

See also: Easiest way to install Mongodb PHP extension in Ubuntu 13.10 (saucy)? 另请参见: 在Ubuntu 13.10(saucy)中安装Mongodb PHP扩展的最简单方法?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM