从 5.3 升级到 Symfony 6

Upgrading to Symfony 6 from 5.3

我更新了我的 composer.json 文件以反映 6.0.* 的变化,运行 我的 composer update "symfony/*" 代码,它返回了这个:

    Problem 1
    - doctrine/doctrine-bundle is locked to version 2.4.3 and an update of this package was not requested.
    - doctrine/doctrine-bundle 2.4.3 requires symfony/config ^4.4.3|^5.0|^6.0 -> found symfony/config[v4.4.3, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 2
    - sensio/framework-extra-bundle is locked to version v5.6.1 and an update of this package was not requested.
    - sensio/framework-extra-bundle v5.6.1 requires symfony/config ^4.4|^5.0 -> found symfony/config[v4.4.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 3
    - Root composer.json requires symfony/security-http 6.0.* -> satisfiable by symfony/security-http[v6.0.0-BETA1, ..., 6.0.x-dev].
    - symfony/security-http[v6.0.0-BETA1, ..., 6.0.x-dev] require symfony/http-kernel ^5.4|^6.0 -> found symfony/http-kernel[v5.4.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 4
    - symfonycasts/reset-password-bundle is locked to version v1.10.0 and an update of this package was not requested.
    - symfonycasts/reset-password-bundle v1.10.0 requires symfony/config ^4.4 | ^5.0 | ^6.0 -> found symfony/config[v4.4.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 5
    - symfonycasts/verify-email-bundle is locked to version v1.6.0 and an update of this package was not requested.
    - symfonycasts/verify-email-bundle v1.6.0 requires symfony/config ^4.4 | ^5.0 | ^6.0 -> found symfony/config[v4.4.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 6
    - doctrine/doctrine-fixtures-bundle is locked to version 3.4.1 and an update of this package was not requested.
    - doctrine/doctrine-fixtures-bundle 3.4.1 requires symfony/config ^3.4|^4.3|^5.0|^6.0 -> found symfony/config[v3.4.0-BETA1, ..., 3.4.x-dev, v4.3.0-BETA1, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev] but these were not loaded, likely because it conflicts with another require.
  Problem 7
    - doctrine/doctrine-bundle 2.4.3 requires symfony/config ^4.4.3|^5.0|^6.0 -> found symfony/config[v4.4.3, ..., 4.4.x-dev, v5.0.0-BETA1, ..., 5.4.x-dev, v6.0.0-BETA1, ..., 6.1.x-dev] but these were not loaded, likely because it conflicts with another require.
    - doctrine/doctrine-migrations-bundle 3.2.1 requires doctrine/doctrine-bundle ~1.0|~2.0 -> satisfiable by doctrine/doctrine-bundle[2.4.3].
    - doctrine/doctrine-migrations-bundle is locked to version 3.2.1 and an update of this package was not requested.

其中一些通知让我感到困惑,因为我不确定当包被锁定版本时该怎么做。

这是我的 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",
        "phpdocumentor/reflection-docblock": "^5.2",
        "sensio/framework-extra-bundle": "^5.1",
        "stripe/stripe-php": "^7.76",
        "symfony/asset": "6.0.*",
        "symfony/console": "6.0.*",
        "symfony/dotenv": "6.0.*",
        "symfony/expression-language": "6.0.*",
        "symfony/flex": "^1.3.1",
        "symfony/form": "6.0.*",
        "symfony/framework-bundle": "5.3.*",
        "symfony/http-client": "6.0.*",
        "symfony/intl": "6.0.*",
        "symfony/mailer": "6.0.*",
        "symfony/mime": "6.0.*",
        "symfony/monolog-bundle": "^3.7",
        "symfony/notifier": "6.0.*",
        "symfony/postmark-mailer": "6.0.*",
        "symfony/process": "6.0.*",
        "symfony/property-access": "6.0.*",
        "symfony/property-info": "6.0.*",
        "symfony/proxy-manager-bridge": "6.0.*",
        "symfony/rate-limiter": "6.0.*",
        "symfony/security-bundle": "6.0.*",
        "symfony/security-core": "6.0.*",
        "symfony/security-csrf": "6.0.*",
        "symfony/security-guard": "5.3.*",
        "symfony/security-http": "6.0.*",
        "symfony/serializer": "6.0.*",
        "symfony/string": "6.0.*",
        "symfony/translation": "6.0.*",
        "symfony/twig-bundle": "^5.3",
        "symfony/validator": "6.0.*",
        "symfony/web-link": "6.0.*",
        "symfony/webpack-encore-bundle": "^1.11",
        "symfony/yaml": "6.0.*",
        "symfonycasts/reset-password-bundle": "^1.7",
        "symfonycasts/verify-email-bundle": "^1.3",
        "taxjar/taxjar-php": "^1.10",
        "twig/cssinliner-extra": "^3.3",
        "twig/extra-bundle": "^3.3",
        "twig/inky-extra": "^3.3",
        "twig/intl-extra": "^3.3",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "symfony/browser-kit": "^5.3",
        "symfony/css-selector": "^5.3",
        "symfony/debug-bundle": "^5.3",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "^5.3",
        "symfony/stopwatch": "^5.3",
        "symfony/var-dumper": "^5.3",
        "symfony/web-profiler-bundle": "^5.3"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "allow-plugins": {
            "symfony/flex": 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": "6.0.*"
        }
    }
}

我该如何解决这些问题以及我可以做些什么才能进一步了解如何自行解决这些问题?

composer.json 文件有点乱。一些 Symfony 包在 5.3 上,一些甚至在 5.1 上,还有很多在 6.

您还从 extra.symfony.require 控制 Symfony 版本控制,同时从离散版本约束控制。您包括了一些在 6.0 (symfony/security-guard) 上不再存在的软件包,并且缺少一些 应该 在 6.0 版本上安装的软件包。

它根本不处于可安装状态。

我已经设法让它可以安装,像这样改变它:

{
    "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",
        "phpdocumentor/reflection-docblock": "^5.2",
        "sensio/framework-extra-bundle": "^6.0.0",
        "stripe/stripe-php": "^7.76",
        "symfony/asset": "*",
        "symfony/console": "*",
        "symfony/dotenv": "*",
        "symfony/expression-language": "*",
        "symfony/flex": "v2.1.4",
        "symfony/form": "*",
        "symfony/framework-bundle": "*",
        "symfony/http-client": "*",
        "symfony/intl": "*",
        "symfony/mailer": "*",
        "symfony/mime": "*",
        "symfony/monolog-bundle": "^3.7",
        "symfony/notifier": "*",
        "symfony/postmark-mailer": "*",
        "symfony/process": "*",
        "symfony/property-access": "*",
        "symfony/property-info": "*",
        "symfony/proxy-manager-bridge": "*",
        "symfony/rate-limiter": "*",
        "symfony/runtime": "*",
        "symfony/security-bundle": "*",
        "symfony/security-core": "*",
        "symfony/security-csrf": "*",
        "symfony/security-http": "*",
        "symfony/serializer": "*",
        "symfony/string": "*",
        "symfony/translation": "*",
        "symfony/twig-bundle": "*",
        "symfony/validator": "*",
        "symfony/web-link": "*",
        "symfony/webpack-encore-bundle": "^1.11",
        "symfony/yaml": "*",
        "symfonycasts/reset-password-bundle": "^1.7",
        "symfonycasts/verify-email-bundle": "^1.3",
        "taxjar/taxjar-php": "^1.10",
        "twig/cssinliner-extra": "^3.3",
        "twig/extra-bundle": "^3.3",
        "twig/inky-extra": "^3.3",
        "twig/intl-extra": "^3.3",
        "twig/twig": "^2.12|^3.0"
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.4",
        "symfony/browser-kit": "*",
        "symfony/css-selector": "*",
        "symfony/debug-bundle": "*",
        "symfony/maker-bundle": "^1.0",
        "symfony/phpunit-bridge": "*",
        "symfony/stopwatch": "*",
        "symfony/var-dumper": "*",
        "symfony/web-profiler-bundle": "*"
    },
    "config": {
        "optimize-autoloader": true,
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "allow-plugins": {
            "symfony/flex": true,
            "composer/package-versions-deprecated": false,
            "symfony/runtime": 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": "6.0.*",
            "docker": true
        }
    }
}

由于这与您的锁定版本不匹配,我将删除您的 vendor 目录以及您的 composer.lock 和 运行 composer install。您将不得不处理新配方的所有不同变化,但希望这是 version-controlled 项目,因此需要仔细检查这些变化并查看出现的问题。

会很有趣。