简体   繁体   English

Composer 显示 2 个兼容包之间的冲突(原始)

[英]Composer shows conflict between 2 compatible packages (original)

I have an error trying to composer install my dependencies.我在尝试composer install我的依赖项时出错。 Same error with composer update .composer update相同的错误。

It says there's a conflict between symfony/web-server-bundle 4.3.3 and symfony 3.4 but those packages are supposed to be compatible:它说 symfony/web-server-bundle 4.3.3 和 symfony 3.4 之间存在冲突,但这些包应该是兼容的:

Here is my console output:这是我的控制台输出:

$ composer install --ignore-platform-reqs
Deprecation warning: Your package name theredled/. is invalid, it should have a vendor name, a forward slash, and a package name. The vendor and package name can be words separated by -, . or _. The complete name should match "[a-z0-9]([_.-]?[a-z0-9]+)*/[a-z0-9]([_.-]?[a-z0-9]+)*". Make sure you fix this as Composer 2.0 will error.
Deprecation warning: require.beberlei/DoctrineExtensions is invalid, it should not contain uppercase characters. Please use beberlei/doctrineextensions instead. Make sure you fix this as Composer 2.0 will error.
Loading composer repositories with package information
Installing dependencies (including require-dev) from lock file
Your requirements could not be resolved to an installable set of packages.

  Problem 1
    - Installation request for symfony/symfony v3.4.30 -> satisfiable by symfony/symfony[v3.4.30].
    - don't install symfony/web-server-bundle v4.3.3|don't install symfony/symfony v3.4.30
    - Installation request for symfony/web-server-bundle v4.3.3 -> satisfiable by symfony/web-server-bundle[v4.3.3].

Here is my composer.json:这是我的 composer.json:

{
    "name": "theredled/.",
    "license": "proprietary",
    "type": "project",
    "autoload": {
        "psr-4": {
            "": "src/"
        },
        "classmap": [
            "app/AppKernel.php",
            "app/AppCache.php"
        ]
    },
    "autoload-dev": {
          "psr-4": {
              "App\\Tests\\": "tests/"
          }
      },
    "require": {
        "php": ">=7.1.0",
        "symfony/symfony": "3.4.*",
        "doctrine/orm": "~2.6",
        "doctrine/doctrine-bundle": "~1.9",
        "symfony/swiftmailer-bundle": "~3.2",
        "symfony/monolog-bundle": "~3.3",
        "sensio/distribution-bundle": "~5.0",
        "incenteev/composer-parameter-handler": "~2.1",
        "twig/extensions": "^1.5",
        "liip/imagine-bundle": "^2.1",
        "spe/filesize-extension-bundle": "~1.0.0",
        "doctrine/doctrine-migrations-bundle": "^1.3",
        "beberlei/DoctrineExtensions": "^1.1",
        "excelwebzone/recaptcha-bundle": "^1.5",
        "knplabs/knp-snappy-bundle": "^1.5",
        "knplabs/knp-paginator-bundle": "^2.8",
        "debesha/doctrine-hydration-profiler-bundle": "^1.3",
        "xmon/color-picker-type-bundle": "^1.0",
        "symfony/assetic-bundle": "^2.8",
        "symfony/console": "~3.4",
        "eightpoints/guzzle-bundle": "^7.4",
        "symfony/webpack-encore-bundle": "^1.6",
        "sentry/sentry-symfony": "^2.1",
        "cocur/slugify": "^3.2"
    },
    "require-dev": {
        "sensio/generator-bundle": "~3.0",
        "symfony/browser-kit": "^4.3",
        "symfony/css-selector": "^4.3",
        "symfony/phpunit-bridge": "^4.3",
        "onurb/doctrine-yuml-bundle": "1.1.5",
        "phpunit/php-code-coverage": "^6.1",
        "hautelook/alice-bundle": "^2.5",
        "doctrine/data-fixtures": "^1.3",
        "symfony/web-server-bundle": "^4.3"
    },
    "scripts": {
        "post-install-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ],
        "post-update-cmd": [
            "Incenteev\\ParameterHandler\\ScriptHandler::buildParameters",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::buildBootstrap",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::clearCache",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installAssets",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::installRequirementsFile",
            "Sensio\\Bundle\\DistributionBundle\\Composer\\ScriptHandler::prepareDeploymentTarget"
        ]
    },
    "config": {
        "bin-dir": "bin",
        "platform": {
            "php": "7.1.11"
        }
    },
    "extra": {
        "symfony-app-dir": "app",
        "symfony-web-dir": "web",
        "symfony-assets-install": "relative",
        "incenteev-parameters": {
            "file": "app/config/parameters.yml"
        },
        "symfony": {
            "allow-contrib": "true"
        }
    }
}

Any idea?任何的想法?

As I described it in another answer recently , you do get this error message because symfony/symfony acts as a replacement of symfony/web-server-bundle at its exact same version, because of this line: https://github.com/symfony/symfony/blob/3.4/composer.json#L85正如我最近另一个答案中所描述的那样,您确实收到了此错误消息,因为symfony/symfony在其完全相同的版本中充当了symfony/web-server-bundle的替代品,因为这一行: https : //github.com/ symfony/symfony/blob/3.4/composer.json#L85

The composer documentation tells you exactly that and takes Symfony as an example to explain the replace section: composer 文档准确地告诉你这一点,并以 Symfony 为例来解释replace部分:

This is also useful for packages that contain sub-packages, for example the main symfony/symfony package contains all the Symfony Components which are also available as individual packages.这对于包含子包的包也很有用,例如主 symfony/symfony 包包含所有 Symfony 组件,它们也可以作为单独的包使用。 If you require the main package it will automatically fulfill any requirement of one of the individual components, since it replaces them.如果您需要主包,它将自动满足单个组件之一的任何要求,因为它会替换它们。

Source: https://getcomposer.org/doc/04-schema.md#replace来源: https : //getcomposer.org/doc/04-schema.md#replace

So with your composer.json as it stands, you are instructing composer to install symfony/web-server-bundle at the version 4.3.3 and to install symfony/web-server-bundle at the version 3.4.30 (via the request to install symfony/symfony at version 3.4.30 , that says it replace that package), and composer end up in an incompatible state, as explained by the error, to install a package at two different version at the same time.因此,与您的composer.json因为它的立场,即是在指示作曲家安装symfony/web-server-bundle在版本4.3.3和安装symfony/web-server-bundle在版本3.4.30 (通过请求在版本3.4.30安装symfony/symfony ,它说它替换了那个包),并且 composer 最终处于不兼容状态,正如错误所解释的那样,同时安装两个不同版本的包。

- don't install symfony/web-server-bundle v4.3.3|don't install symfony/symfony v3.4.30
- Installation request for symfony/web-server-bundle v4.3.3 -> satisfiable by symfony/web-server-bundle[v4.3.3].

=> don't install symfony/web-server-bundle is really what it means: you actually don't need it, it is part of symfony/symfony already =>不安装symfony/web-server-bundle真的是它的意思:你实际上不需要它,它已经是symfony/symfony一部分

From here you have three options:从这里你有三个选择:

  1. You remove the requirement for symfony/web-server-bundle in your composer.json (but that means you will have to live with that package at the version 3.4.30 , as provided by symfony/symfony )您在composer.json删除了symfony/web-server-bundle的要求(但这意味着您必须使用3.4.30版本的软件包,由symfony/symfony
  2. You upgrade your symfony/symfony package to 4.3.3 (still leaving the requirement of symfony/web-server-bundle out of your composer.json because symfony/symfony does replace it).您将symfony/symfony包升级到4.3.3 (仍然将symfony/web-server-bundlecomposer.json排除,因为symfony/symfony确实替换了它)。
  3. You require the symfony/* package that you need one by one, but not via the "super-package" symfony/symfony .您需要一个一个需要的symfony/*包,但不是通过“超级包” symfony/symfony
    That's more work and more possible incompatibilities to deal with in a long term, but that is the only way to have symfony/web-server-bundle at version ^4.0 when still having other Symfony packages in versions ^3.0 .从长远来看,这是更多的工作和更多可能的不兼容问题,但这是在^4.0版本中拥有symfony/web-server-bundle的唯一方法,同时在^3.0版本中仍有其他 Symfony 包。
    An example of that would be to replace this line of your composer.json :一个例子是替换composer.json这一行:

     "symfony/symfony": "3.4.*",

    with

    "symfony/asset": "3.4.*", "symfony/browser-kit": "3.4.*", "symfony/cache": "3.4.*", "symfony/class-loader": "3.4.*", "symfony/config": "3.4.*", "symfony/console": "3.4.*", "symfony/css-selector": "3.4.*", "symfony/dependency-injection": "3.4.*", "symfony/debug": "3.4.*", "symfony/debug-bundle": "3.4.*", "symfony/doctrine-bridge": "3.4.*", "symfony/dom-crawler": "3.4.*", "symfony/dotenv": "3.4.*", "symfony/event-dispatcher": "3.4.*", "symfony/expression-language": "3.4.*", "symfony/filesystem": "3.4.*", "symfony/finder": "3.4.*", "symfony/form": "3.4.*", "symfony/framework-bundle": "3.4.*", "symfony/http-foundation": "3.4.*", "symfony/http-kernel": "3.4.*", "symfony/inflector": "3.4.*", "symfony/intl": "3.4.*", "symfony/ldap": "3.4.*", "symfony/lock": "3.4.*", "symfony/monolog-bridge": "3.4.*", "symfony/options-resolver": "3.4.*", "symfony/process": "3.4.*", "symfony/property-access": "3.4.*", "symfony/property-info": "3.4.*", "symfony/proxy-manager-bridge": "3.4.*", "symfony/routing": "3.4.*", "symfony/security": "3.4.*", "symfony/security-core": "3.4.*", "symfony/security-csrf": "3.4.*", "symfony/security-guard": "3.4.*", "symfony/security-http": "3.4.*", "symfony/security-bundle": "3.4.*", "symfony/serializer": "3.4.*", "symfony/stopwatch": "3.4.*", "symfony/templating": "3.4.*", "symfony/translation": "3.4.*", "symfony/twig-bridge": "3.4.*", "symfony/twig-bundle": "3.4.*", "symfony/validator": "3.4.*", "symfony/var-dumper": "3.4.*", "symfony/web-link": "3.4.*", "symfony/web-profiler-bundle": "3.4.*", "symfony/workflow": "3.4.*", "symfony/yaml": "3.4.*"

    Which I just created by copying the replace section of symfony/symfony 's composer.json , where I replaced the "self.version" by your actual symfony/symfony version, and finally, removed the package symfony/web-server-bundle , since you require it on another version already.我只是通过复制symfony/symfonycomposer.jsonreplace部分创建的,在那里我用你的实际symfony/symfony版本替换了"self.version" ,最后,删除了包symfony/web-server-bundle ,因为您已经在另一个版本上需要它。

As for your misunderstanding of the composer.json of symfony/web-server-bundler , this package is indeed compatibe with the packages of Symfony at version ^4.0 that are listed:至于你对symfony/web-server-bundlercomposer.json的误解,这个包确实与 Symfony ^4.0版本的包兼容,如下所示:

  • symfony/config symfony/配置
  • symfony/console symfony/控制台
  • symfony/dependency-injection symfony/依赖注入
  • symfony/http-kernel symfony/http-内核
  • symfony/polyfill-ctype symfony/polyfill-ctype
  • symfony/process symfony/进程

But not with the bundled "super-package" symfony/symfony that is indeed not present in the require section of its composer.json不能与捆绑的“超级包” symfony/symfony的确是不存在需要它的部分composer.json

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM