2017-08-03 102 views
1

如何在Mac機器上使用composer安裝PHP擴展Mongo?我使用以下命令通過composer安裝PHP擴展。無法使用Composer安裝PHP擴展mongo

composer install --prefer-source 

我得到了以下例外。

[email protected]:/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. 

注:

我已經在Mac機上安裝MongoDB中,安裝的版本是

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

你試過Google嗎? http://php.net/manual/en/mongodb.installation.homebrew.php – localheinz

回答

1

學說/ MongoDB中的1.4.x-dev的需要EXT-蒙戈^ 1.5 - >的請求的PHP擴展mongo從您的系統中丟失。

似乎沒有安裝php mongodb擴展。所以請看mongodb documentation php driver

如果安裝了php-dev軟件包,您可以簡單地通過pecl安裝此擴展程序 - 具體取決於您的php版本。

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

重新啓動php並重新運行作曲家並檢查其輸出。

好的,在Mac上它看起來有點不同,因爲你可以閱讀here(12.)。