symfonycomposer-phpsymfony-flex

Why do I get this error when I attempt to upgrade Symfony by changing `extra.symfony.require`?


I am trying to upgrade from Symfony 5.2 to Symfony 5.3.

I don't know which packages to update Symfony so I was using the official site, and I have followed both:

https://symfony.com/doc/current/setup/upgrade_major.html

And also https://symfony.com/doc/current/setup/upgrade_minor.html which said to update:

      "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.*",

and I get the same composer errors.

Some of the commands ran:

composer update "symfony/*" --with-all-dependencies
composer update

and the 'Updating Recipes' section, updated all that required it.

The error remains the same:

>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.*"
        }
    }
}

Solution

  • You have conflicting requirements.

    On extra.symfony.require you say you want 5.3.*.

    But on your individual Symfony requirements you are specifying either ^5.2 or 5.2.* (and in some cases ^5.3 as well).

    When a project uses Symfony Flex (as is your case), the presence of extra.symfony.require will be used to restrict what package versions to install for many/most Symfony packages. But only if you do not declare a specific version on your require section.

    In this case, you are already specifying a version on the 5.* range on extra.symfony.require. Leave that one like that, and just use * as a version constraint for all the other Symfony Packages in the require section.

    (Note that's it's not really all, since some packages are not managed by Flex, just update the ones that have versions declares in the 5.* range)