无法在 Symfony 5.1 中安装 orm-pack

Posted

技术标签:

【中文标题】无法在 Symfony 5.1 中安装 orm-pack【英文标题】:Couldn't install orm-pack in Symfony 5.1 【发布时间】:2020-10-30 12:17:04 【问题描述】:

我正在尝试在我的 Symfony 5.1 项目中安装 Doctrine ORM,但出现以下错误:

composer require symfony/orm-pack
Using version ^1.1 for symfony/orm-pack
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Restricting packages listed in "symfony/symfony" to "5.1.*"
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - doctrine/doctrine-migrations-bundle v2.0.0 requires symfony/framework-bundle ~3.4|~4.0 -> no matching package found.
    - Installation request for symfony/orm-pack ^1.1 -> satisfiable by symfony/orm-pack[v1.1.0].
    - Conclusion: remove doctrine/doctrine-migrations-bundle 3.0.1
    - Conclusion: don't install doctrine/doctrine-migrations-bundle 3.0.1
    - symfony/orm-pack v1.1.0 requires doctrine/doctrine-migrations-bundle ^2 -> satisfiable by doctrine/doctrine-migrations-bundle[2.1.0, 2.1.1, 2.1.2, v2.0.0].
    - Can only install one of: doctrine/doctrine-migrations-bundle[2.1.0, 3.0.1].
    - Can only install one of: doctrine/doctrine-migrations-bundle[2.1.1, 3.0.1].
    - Can only install one of: doctrine/doctrine-migrations-bundle[2.1.2, 3.0.1].
    - Installation request for doctrine/doctrine-migrations-bundle (locked at 3.0.1) -> satisfiable by doctrine/doctrine-migrations-bundle[3.0.1].

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://getcomposer.org/doc/04-schema.md#minimum-stability> for more details.
 - It's a private package and you forgot to add a custom repository to find it

Read <https://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Installation failed, reverting ./composer.json to its original content.

我需要哪些版本才能在 Symfony 5.1 中使用 Doctrine? 我试过安装

composer req doctrine/doctrine-migrations-bundle:2.0
composer require symfony/orm-pack:1.1

但都失败了。

【问题讨论】:

【参考方案1】:

已经有一些关于此的问题,请参阅 https://github.com/symfony/orm-pack/issues/18 或 https://github.com/symfony/orm-pack/issues/29 - 问题:自上一个版本以来,ORM 包需要 Doctrine v2。而且根据你提供的包列表,在此之前你需要doctrine/doctrine-migrations-bundle 3.0.1

有两种可能的解决方案:将doctrine/doctrine-migrations-bundle 和其他与 Doctrine 相关的包降级到 v2 直到错误消息消失,或者跳过 ORM 包并要​​求在该包中编写的包。如果您已经安装了迁移包,那么额外安装 symfony/orm-pack 没有任何好处

【讨论】:

非常感谢,我选择了第二个选项,现在一切正常。【参考方案2】:

致在尝试要求 orm-pack、here's the key 时遇到“无法解析版本约束 orm-pack”错误的任何人,然后运行:

composer require orm

https://github.com/symfony/flex/issues/820#issuecomment-942016309

【讨论】:

以上是关于无法在 Symfony 5.1 中安装 orm-pack的主要内容,如果未能解决你的问题,请参考以下文章

无法在 Symfony2 2.4 中安装 SonataUserBundle

无法在 Symfony 4.1 项目中安装 Doctrine Migrations V2

我无法在 Symfony 4 中安装 Sonata SEO Bundle

我可以在不使用 composer 甚至在 XAMPP 中安装 Symfony 的情况下运行 Symfony 项目吗?

在现有项目中安装 Symfony CMF

在 Symfony 2 项目中安装 Bootstrap 主题