当我尝试用作曲家安装doctrine/mongodb-odm-bundle和doctrine/mongodb时,它会抛出错误。
composer require doctrine/mongodb-odm-bundle doctrine/mongodb
Using version ^3.5 for doctrine/mongodb-odm-bundle
Using version ^1.6 for doctrine/mongodb
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/mongodb 1.6.3 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.6.2 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.6.1 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- doctrine/mongodb 1.6.0 requires ext-mongo ^1.6.7 -> the requested PHP extension mongo is missing from your system.
- Installation request for doctrine/mongodb ^1.6 -> satisfiable by doctrine/mongodb[1.6.0, 1.6.1, 1.6.2, 1.6.3].
To enable extensions, verify that they are enabled in your .ini files:
-
- /usr/local/etc/php/conf.d/docker-php-ext-mongodb.ini
- /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini
- /usr/local/etc/php/conf.d/docker-php-ext-soap.ini
- /usr/local/etc/php/conf.d/docker-php-ext-sodium.ini
- /usr/local/etc/php/conf.d/docker-php-ext-zip.ini
You can also run `php --ini` inside terminal to see which files are used by PHP in CLI mode.
Installation failed, reverting ./composer.json to its original content.
我很惊讶看到此错误消息,因为我确实使用 pecl 安装了 Mongodb 并使用 ini 文件启用了它。
RUN pecl install mongodb
&& docker-php-ext-enable mongodb
有谁知道如何解决这个问题?
我认为
通过将带有ext-mongo的提供部分添加到composer.json文件中,问题得到了解决
"provide" : {
"ext-mongo": "*"
}
它似乎完全忽略了 php 扩展。