简体   繁体   English

无法使用Composer安装PHP扩展mongo

[英]Can't install PHP extension mongo with Composer

How to install PHP extension Mongo with composer in mac machine? 如何在Mac机器中使用composer安装PHP扩展Mongo? I use following command to install PHP extension with composer. 我使用以下命令通过composer安装PHP扩展。

composer install --prefer-source

I got the following exceptions. 我有以下例外。

vagrant@vagrant:/var/www$ composer install --prefer-source
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Warning: The lock file is not up to date with the latest changes in composer.json. You may be getting outdated dependencies. Run update to update them.
Your requirements could not be resolved to an installable set of packages.

  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
    - Installation request for doctrine/mongodb dev-master -> satisfiable by doctrine/mongodb[dev-master].
    - doctrine/mongodb dev-master requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system.
  Problem 3
    - doctrine/mongodb 1.4.x-dev requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system.
    - doctrine/mongodb-odm dev-master requires doctrine/mongodb ~1.3 -> satisfiable by doctrine/mongodb[1.4.x-dev].
    - Installation request for doctrine/mongodb-odm dev-master -> satisfiable by doctrine/mongodb-odm[dev-master].

  To enable extensions, verify that they are enabled in your .ini files:
    - /etc/php5/cli/php.ini
    - /etc/php5/cli/conf.d/05-opcache.ini
    - /etc/php5/cli/conf.d/10-pdo.ini
    - /etc/php5/cli/conf.d/20-curl.ini
    - /etc/php5/cli/conf.d/20-json.ini
    - /etc/php5/cli/conf.d/20-readline.ini
  You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.

Note: 注意:

I have installed MongoDB in mac machine, installed version is 我已经在Mac机器上安装了MongoDB,安装的版本是

Shyleen:~ shyleenrodrigues$ mongo --version
MongoDB shell version v3.4.6

doctrine/mongodb 1.4.x-dev requires ext-mongo ^1.5 -> the requested PHP extension mongo is missing from your system. doctrine / mongodb 1.4.x-dev需要ext-mongo ^ 1.5->系统中缺少所请求的PHP扩展mongo。

It seems that the php mongodb extension is not installed. 似乎未安装php mongodb扩展。 So please see mongodb documentation php driver . 因此,请参阅mongodb文档php驱动程序

You can simply install this extension via pecl , if php-dev package is installed - depending on your php version. 如果安装了php-dev软件包,则可以简单地通过pecl安装此扩展-取决于您的php版本。

sudo apt-get install php7.0-dev // for example on ubuntu linux!!
sudo pecl install mongodb

Restart php and rerun the composer and check its output. 重新启动php并重新运行作曲器并检查其输出。

Ok, on mac it seems like a bit different as you can read here (12.). 好的,在Mac上,您可以在此处阅读(12.)似乎有点不同。

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

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