当我尝试通过更改 `extra.symfony.require` 来升级 Symfony 时,为啥会出现此错误?
Posted
技术标签:
【中文标题】当我尝试通过更改 `extra.symfony.require` 来升级 Symfony 时,为啥会出现此错误?【英文标题】:Why do I get this error when I attempt to upgrade Symfony by changing `extra.symfony.require`?当我尝试通过更改 `extra.symfony.require` 来升级 Symfony 时,为什么会出现此错误? 【发布时间】:2021-11-17 13:50:56 【问题描述】:我正在尝试从 Symfony 5.2 升级到 Symfony 5.3。
我不知道要更新哪些软件包,所以我使用的是官方网站,并且我都关注了:
https://symfony.com/doc/current/setup/upgrade_major.html
还有说要更新的https://symfony.com/doc/current/setup/upgrade_minor.html:
"require":
- "symfony/cache": "4.3.*",
+ "symfony/cache": "4.4.*",
- "symfony/config": "4.3.*",
+ "symfony/config": "4.4.*",
- "symfony/console": "4.3.*",
+ "symfony/console": "4.4.*",
我得到同样的作曲家错误。
一些命令运行:
composer update "symfony/*" --with-all-dependencies
composer update
“更新食谱”部分更新了所有需要的内容。
错误依旧:
>composer update
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "5.3.*"
Updating dependencies
Your requirements could not be resolved to an installable set of packages.
Problem 1
- symfony/web-profiler-bundle[v5.3.0-BETA1, ..., 5.3.x-dev] require symfony/framework-bundle ^5.3 -> found symfony/framework-bundle[v5.3.0-BETA1, ..., 5.4.x-dev] but it conflicts with your root composer.json require (5.2.*).
- Root composer.json requires symfony/web-profiler-bundle ^5.2 -> satisfiable by symfony/web-profiler-bundle[v5.3.0-BETA1, ..., 5.3.x-dev].
Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.
composer.json
"type": "project",
"license": "proprietary",
"minimum-stability": "dev",
"prefer-stable": true,
"require":
"php": ">=7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"composer/package-versions-deprecated": "1.11.99.1",
"doctrine/annotations": "^1.0",
"doctrine/doctrine-bundle": "^2.3",
"doctrine/doctrine-migrations-bundle": "^3.0",
"doctrine/orm": "^2.8",
"guzzlehttp/guzzle": "^7.3",
"phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^6.1",
"symfony/apache-pack": "^1.0",
"symfony/asset": "5.2.*",
"symfony/console": "5.3.*",
"symfony/dotenv": "5.2.*",
"symfony/expression-language": "5.2.*",
"symfony/flex": "^1.3.1",
"symfony/form": "5.2.*",
"symfony/framework-bundle": "5.2.*",
"symfony/http-client": "5.2.*",
"symfony/intl": "5.2.*",
"symfony/mailer": "5.2.*",
"symfony/mime": "5.2.*",
"symfony/monolog-bundle": "^3.1",
"symfony/notifier": "5.2.*",
"symfony/process": "5.2.*",
"symfony/property-access": "5.2.*",
"symfony/property-info": "5.2.*",
"symfony/proxy-manager-bridge": "5.2.*",
"symfony/rate-limiter": "5.2.*",
"symfony/security-bundle": "5.2.*",
"symfony/sendgrid-mailer": "5.3.*",
"symfony/serializer": "5.2.*",
"symfony/string": "5.2.*",
"symfony/translation": "5.2.*",
"symfony/twig-bundle": "^5.3",
"symfony/validator": "5.2.*",
"symfony/web-link": "5.2.*",
"symfony/webpack-encore-bundle": "^1.11",
"symfony/yaml": "5.2.*",
"symfonycasts/reset-password-bundle": "^1.6",
"symfonycasts/verify-email-bundle": "^1.3",
"twig/extra-bundle": "^2.12|^3.0",
"twig/twig": "^2.12|^3.0"
,
"require-dev":
"symfony/browser-kit": "^5.2",
"symfony/css-selector": "^5.2",
"symfony/debug-bundle": "^5.3",
"symfony/maker-bundle": "^1.30",
"symfony/phpunit-bridge": "^5.2",
"symfony/stopwatch": "^5.2",
"symfony/var-dumper": "^5.2",
"symfony/web-profiler-bundle": "^5.2"
,
"config":
"optimize-autoloader": true,
"preferred-install":
"*": "dist"
,
"sort-packages": true
,
"autoload":
"psr-4":
"App\\": "src/"
,
"autoload-dev":
"psr-4":
"App\\Tests\\": "tests/"
,
"replace":
"symfony/polyfill-ctype": "*",
"symfony/polyfill-iconv": "*",
"symfony/polyfill-php72": "*"
,
"scripts":
"auto-scripts":
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
,
"post-install-cmd": [
"@auto-scripts"
],
"post-update-cmd": [
"@auto-scripts"
]
,
"conflict":
"symfony/symfony": "*"
,
"extra":
"symfony":
"allow-contrib": false,
"require": "5.3.*"
【问题讨论】:
我希望你在我删除之前没有看到我的评论。我说我尝试了 extra.symfony.require = "5.*",我也尝试删除它只是为了看看它是否会有所作为。文档说只有 cache/config/console 就足以升级 Symfony。我明天将从 5.2 开始全新安装,看看是否可以解决升级问题。如果我找到一个,我会发布一张票并链接它,如果我可以发布升级步骤。 再一次,这些事情不是我在回答中建议的,并且会失败。要么按照我在回答中的建议进行操作(保留extra.symfony.require
原样,将所有软件包更改为 *
),或者您必须将每个 symfony
软件包更新为新版本。
【参考方案1】:
您有相互冲突的要求。
在extra.symfony.require
你说你想要5.3.*
。
但是根据您的个人 Symfony 要求,您可以指定 ^5.2
或 5.2.*
(在某些情况下还指定 ^5.3
)。
当项目使用 Symfony Flex(如您的情况)时,extra.symfony.require
的存在将用于限制为许多/大多数 Symfony 包安装的包版本。但前提是您没有在 require
部分声明特定版本。
在这种情况下,您已经在extra.symfony.require
的5.*
范围内指定了一个版本。保留那个,只使用*
作为require
部分中所有其他Symfony 包的版本约束。
(请注意,这并不是真正的全部,因为某些包不是由 Flex 管理的,只需更新那些在 5.*
范围内声明的版本)
【讨论】:
我知道存在冲突,但我不确定为什么以及如何。我一直在尝试关注 symfony.com/doc 和 symfonycasts.com。我尝试使用 --with-all-dependencies 更新食谱和其他软件包。并且错误没有改变。composer update
不会更改您之前设置的版本要求。它只会更新您的依赖项在这些约束内。您需要首先修复您的composer.json
,正如我在回答中指定的那样,然后再次运行composer update
。
我刚刚检查了您对我的问题的更新。而且我没有在我的标题中提到“extra.symfony.require”。但后来你质疑我对extra.symfony.require
的使用,你将其添加到我的问题中......
它在您的composer.json
中,它是冲突的根源。虽然不是唯一的。试图使问题更具体,否则它是一个非常笼统的“我在运行作曲家更新时遇到问题”,在搜索解决方案时可能很难找到。目的是帮助您解决这个问题,并帮助未来的访问者找到问题。
所以令人困惑的是我正在寻找显然不存在的“extra.symfony.require”。我没有意识到您正在更改格式,您本可以在某处提到这一点。 "extra": "symfony": "require": "5.3.*"
。 ...我将 extra.symfony.require 改回 "require": "5.2.*" 但有相同的错误。我将所有内容都置于版本控制之下,但如果可以的话,我宁愿理解问题,也不愿恢复原状。以上是关于当我尝试通过更改 `extra.symfony.require` 来升级 Symfony 时,为啥会出现此错误?的主要内容,如果未能解决你的问题,请参考以下文章
通过 `onmousedown`、`click` 事件更改 `href` 的链接