在 Symfony 5 中使用 composer 安装 EasyAdmin 的问题

Posted

技术标签:

【中文标题】在 Symfony 5 中使用 composer 安装 EasyAdmin 的问题【英文标题】:Issue to install EasyAdmin with composer in Symfony 5 【发布时间】:2020-12-14 16:53:34 【问题描述】:

我在 Symfony 5 中开始了一个新项目,并尝试使用 composer require easycorp/easyadmin-bundle 安装 EasyAdmin,但我发现了一个问题。

作曲家日志:

./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
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.3
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.2
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.1
    - Conclusion: don't install easycorp/easyadmin-bundle v3.1.0
    - Conclusion: don't install easycorp/easyadmin-bundle v3.0.2
    - Conclusion: don't install easycorp/easyadmin-bundle v3.0.1
    - Conclusion: remove doctrine/common 3.0.2
    - Installation request for easycorp/easyadmin-bundle ^3.0 -> satisfiable by easycorp/easyadmin-bundle[v3.0.0, v3.0.1, v3.0.2, v3.1.0, v3.1.1, v3.1.2, v3.1.3].
    - Conclusion: don't install doctrine/common 3.0.2
    - easycorp/easyadmin-bundle v3.0.0 requires doctrine/common ^2.8 -> satisfiable by doctrine/common[2.12.0, 2.13.0, 2.13.1, 2.13.2, 2.13.3, v2.10.0, v2.11.0, v2.8.0, v2.8.1, v2.9.0].
    - Can only install one of: doctrine/common[2.12.0, 3.0.2].
    - Can only install one of: doctrine/common[2.13.0, 3.0.2].
    - Can only install one of: doctrine/common[2.13.1, 3.0.2].
    - Can only install one of: doctrine/common[2.13.2, 3.0.2].
    - Can only install one of: doctrine/common[2.13.3, 3.0.2].
    - Can only install one of: doctrine/common[v2.11.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.10.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.8.0, 3.0.2].
    - Can only install one of: doctrine/common[v2.8.1, 3.0.2].
    - Can only install one of: doctrine/common[v2.9.0, 3.0.2].
    - Installation request for doctrine/common (locked at 3.0.2) -> satisfiable by doctrine/common[3.0.2].

你有解决办法吗?

【问题讨论】:

【参考方案1】:

正如您在错误消息列表中看到的那样:easycorp/easyadmin-bundle 在 v2 中需要 doctrine/common,而您已经安装了 v3。

您应该降级该软件包,以便可以安装管理包。如果您需要这方面的帮助,请将composer.json 的内容添加到您的问题中。

【讨论】:

感谢您的帮助,终于明白了!但是当我尝试升级时,其他依赖项存在问题... 如果升级有其他问题,请为此开新问题【参考方案2】:

Easyadmin 依赖于教义/通用 v2,您需要使用 composer remove doctrine/common 删除当前的教义版本,然后您可以安装 easyadmin

【讨论】:

感谢您的帮助,我也尝试过,但是其他依赖项存在问题... 只需对其他依赖项应用相同的过程【参考方案3】:

尝试像这样更改您的 composer.json 文件:

    "type": "project",
    "license": "proprietary",
    "require": 
        "php": ">=7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "composer/package-versions-deprecated": "^1.11",
        "doctrine/annotations": "^1.10",
        "doctrine/doctrine-bundle": "^2.1",
        "doctrine/doctrine-migrations-bundle": "^3.0",
        "doctrine/orm": "^2.6.3",
    "easycorp/easyadmin-bundle": "3.1",
        "sensio/framework-extra-bundle": "^5.6",
        "symfony/asset": "5.1.*",
        "symfony/console": "5.1.*",
        "symfony/dotenv": "5.1.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "5.1.*",
        "symfony/framework-bundle": "5.1.*",
        "symfony/maker-bundle": "^1.20",
        "symfony/security-bundle": "5.1.*",
        "symfony/stopwatch": "5.1.*",
        "symfony/twig-bundle": "5.1.*",
        "symfony/validator": "5.1.*",
        "symfony/web-profiler-bundle": "5.1.*",
        "symfony/yaml": "5.1.*",
        "twig/extra-bundle": "^2.12|^3.0",
        "twig/twig": "^2.12|^3.0"
    ,


然后输入:sudo composer update。适用于 Ubuntu 18.04 LTS :)

【讨论】:

请解释什么你做了什么改变以及为什么。此外,除非您有充分的理由,否则不应使用 sudo 运行 composer 我已经更改了学说的版本:“doctrine/orm”:“^2.6.3”,并添加了:“easycorp/easyadmin-bundle”:“3.1”,然后一定要更新作曲家。 请通过编辑将所有此类解释添加到您的答案中【参考方案4】:

你需要降级学说/普通和学说/坚持。

试试这个:

composer require doctrine/persistence:1.3.8 doctrine/common:2.13.3

那么你应该可以调用:

symfony composer req "admin:^2.0"

【讨论】:

以上是关于在 Symfony 5 中使用 composer 安装 EasyAdmin 的问题的主要内容,如果未能解决你的问题,请参考以下文章

Symfony - Composer 更新 - 需要使用旧的依赖项(PHP 5.4 到 PHP 5.3)

在 symfony 中使用 SimpleSAMLphp 和 composer

无法使用 symfony 5 安装奏鸣曲管理员

无法通过 composer 和 flex 安装 symfony/console:3.2

加载 Symfony 2.8.3 时,travis+composer 反复失败

无法使用 Symfony 5 安装 FOSRestBundle