我试图将Symfony 6项目与Docker环境中的MongoDB数据库连接起来,但是当我启动以下命令时
composer require doctrine/mongodb-odm
出现此消息
Your requirements could not be resolved to an installable set of packages.
Problem 1
- doctrine/mongodb-odm[1.0.0, ..., 1.0.8] require symfony/console ~2.3|~3.0 -> found symfony/console[v2.3.0, ..., v2.8.52, v3.0.0, ..., v3.4.47] but it conflicts with your root composer.json require (6.1.*).
- doctrine/mongodb-odm[1.1.0, ..., 1.3.7] require php ^5.6 || ^7.0 -> your php version (8.1.12) does not satisfy that requirement.
- Root composer.json requires doctrine/mongodb-odm ^1.0 -> satisfiable by doctrine/mongodb-odm[1.0.0, ..., 1.3.7].
You can also try re-running composer require with an explicit version constraint, e.g. "composer require doctrine/mongodb-odm:*" to figure out if any version is installable, or "composer require doctrine/mongodb-odm:^2.1" if you know which you need.
Installation failed, reverting ./composer.json and ./composer.lock to their original content.
我的Dock合成文件
version: '3.8'
services:
mongo:
image: mongo
restart: always
environment:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
mongo-express:
image: mongo-express
restart: always
ports:
- 8081:8081
environment:
ME_CONFIG_MONGODB_ADMINUSERNAME: root
ME_CONFIG_MONGODB_ADMINPASSWORD: example
ME_CONFIG_MONGODB_URL: mongodb://root:example@mongo:27017/
www:
build: php
container_name: www-docker-env
ports:
- '80:80'
volumes:
- ./php/vhosts:/etc/apache2/sites-enabled
- ./:/var/www
-
type: 'bind'
source: '../project/'
target: '/var/www/'
consistency: 'delegated'
restart: always
networks:
- dev
networks:
dev:
volumes:
mongo-data:
Dockerfile文件
FROM php:8.1-apache
ARG user
ARG uid
RUN echo 'ServerName localhost' >> /etc/apache2/apache2.conf
RUN apt-get update \
&& apt-get install -y --no-install-recommends locales apt-utils git libicu-dev g++ libpng-dev libxml2-dev libzip-dev libonig-dev libxslt-dev \
&& apt install -y unzip;
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && \
echo "fr_FR.UTF-8 UTF_8" >> /etc/locale.gen && \
locale-gen
RUN docker-php-ext-configure intl
RUN docker-php-ext-install pdo pdo_mysql gd opcache intl zip calendar dom mbstring zip gd xsl
RUN pecl install apcu && docker-php-ext-enable apcu
# Clear cache
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
WORKDIR /var/www/
USER $user
以上文件中有没有我没有注意到的地方,下面的问题有没有解决的办法?
1条答案
按热度按时间8yoxcaq71#
如果您想使用PHP 8.1,请将mongodb-odm升级到2.3版。这是第一个支持PHP 8的版本,如this statement中所述:
我们已经发布了Doctrine MongoDB ODM的新次要版本2.3,这是第一个支持使用PHP 8属性作为Map文档的新驱动程序的版本,并在GitHub上进行了一些其他更改。See all changes and contributors in the Changelog
否则,请按照错误消息中的指示降级到PHP 7.0。