2

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.*"
        }
    }
}
yivi
  • 42,438
  • 18
  • 116
  • 138
Bradmage
  • 1,233
  • 1
  • 15
  • 41
  • I hoped you didn't see my comment before I deleted it. I was saying I tried extra.symfony.require = "5.*", and I also tried deleting it just to see if it would make a difference. And the docs say only cache/config/console are enough to upgrade Symfony. I'm going to start a fresh install from 5.2 tomorrow and see if I can workout an upgrade issue. If I find one I'll post a ticket and link it, and if I can post upgrade steps. – Bradmage Sep 24 '21 at 11:36
  • 1
    Again, those things are not what I suggested in my answer, and will fail. Either do what I advise in my answer (leave `extra.symfony.require`as it is, change all packages to `*`), or you'll have to update each `symfony` package to the new version. – yivi Sep 24 '21 at 11:42

1 Answers1

4

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)

yivi
  • 42,438
  • 18
  • 116
  • 138
  • I understand there are conflicts, I'm just not sure why and how. I've been trying to follow symfony.com/doc and https://symfonycasts.com/. I've tried updating recipes and other packages with --with-all-dependencies. and the error hasn't changed. – Bradmage Sep 24 '21 at 10:17
  • `composer update` will not change the version requirements you have set previously. It will only update your dependencies **within those constraints**. You need to first fix your `composer.json` as I specify in my answer, and the run `composer update` again. – yivi Sep 24 '21 at 10:18
  • I just checked your update to my question. And I didn't mention 'extra.symfony.require' in my title. But then you questioned my use of `extra.symfony.require` which you added to my question.. – Bradmage Sep 24 '21 at 10:27
  • It's in your `composer.json`, and it's the source of the conflict. Although not the only one. Trying to make the question more specific, since otherwise it's a very general "I have issues running composer update", which can be difficult to find when searching for solutions. The aim is to help both you with this issue, and future visitors to find the question. – yivi Sep 24 '21 at 10:27
  • So the confusion was I was doing a find for "extra.symfony.require" which obviously doesn't exist. I didn't realise you were changing the format, you could have mentioned that somewhere. `"extra": { "symfony": { "require": "5.3.*" } }`. ... I changed extra.symfony.require back to "require": "5.2.*" but have the same errors. I have everything under version control but I'd rather understand the problem than revert back if I can. – Bradmage Sep 24 '21 at 10:47
  • It's the common way to refer to object properties. The composer.json format simply describes an object. My answer didn't say you had to change that to 5.2. It says you need to change all the other `symfony/package` versions to `*`, and leave `extra.symfony.require` as `5.3.*`. (eg. `"symfony/dotenv": "*"`, `"symfony/asset": "*"`, etc). – yivi Sep 24 '21 at 10:49
  • I reread your answer when I got up and it clicked straight away. I was somehow other thinking what you were saying, or a bit confused trying to find Symfony core packages like listed in the docs. But you meant setting them all like this `"symfony/validator": "*"` done and is working. – Bradmage Sep 24 '21 at 23:22