DEV Community

JerDox
JerDox

Posted on

Updating Symfony 4.2 to 4.4

I've worked a long time with Symfony 4.2 and I never had the need to update it in the last years.

But now I it seems to me that I have to update min. to version 4.4. because of an error in the maker-bundle which was seems to be fixed in a version that needs Symfony 4.4. (GitHub Issue)

So let's start:
In my existing Symfony Project my composer.json looking like this:

{
    "type": "project",
    "license": "proprietary",
    "require": {
        "php": "^7.1.3",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "api-platform/core": "2.1",
        "doctrine/annotations": "^1.0",
        "doctrine/doctrine-bundle": "^1.11",
        "doctrine/doctrine-migrations-bundle": "^2.0",
        "doctrine/orm": "^2.7",
        "nelmio/cors-bundle": "^1.5 || ^2.0",
        "phpdocumentor/reflection-docblock": "^3.0 || ^4.0 || ^5.0",
        "sensio/framework-extra-bundle": "^5.2",
        "symfony/apache-pack": "^1.0",
        "symfony/asset": "4.2.*",
        "symfony/console": "4.2.*",
        "symfony/dotenv": "4.2.*",
        "symfony/expression-language": "4.2.*",
        "symfony/flex": "^1.1",
        "symfony/framework-bundle": "4.2.*",
        "symfony/security-bundle": "4.2.*",
        "symfony/twig-bundle": "4.2.*",
        "symfony/validator": "4.2.*",
        "symfony/webpack-encore-bundle": "^1.7",
        "symfony/yaml": "4.2.*"
    },
    "config": {
        "preferred-install": {
            "*": "dist"
        },
        "sort-packages": true,
        "allow-plugins": {
            "ocramius/package-versions": true,
            "symfony/flex": true
        }
    },
    "autoload": {
        "psr-4": {
            "App\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "App\\Tests\\": "tests/"
        }
    },
    "replace": {
        "paragonie/random_compat": "2.*",
        "symfony/polyfill-ctype": "*",
        "symfony/polyfill-iconv": "*",
        "symfony/polyfill-php71": "*",
        "symfony/polyfill-php70": "*",
        "symfony/polyfill-php56": "*"
    },
    "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": "4.2.*"
        }
    },
    "require-dev": {
        "symfony/debug-bundle": "4.2.*",
        "symfony/maker-bundle": "^1.35.0",
        "symfony/monolog-bundle": "^3.0",
        "symfony/stopwatch": "4.2.*",
        "symfony/web-profiler-bundle": "4.2.*"
    }
}


Enter fullscreen mode Exit fullscreen mode

1. Step:
I changed all references of "symfony/..." with the version "4.2" inside to "4.4.*" ('*' is specify a wildcard. That means that the updates can be >= 4.4.0 and < 4.5 if I've understand that correctly) (composer docs)

2. Step:
I open a terminal and navigate to the directory where the Symfony-Project is lives in and run:

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

... and YES for my surprise it succeeded without any error message. This was much easier as I expected.

There is also a good tutorial for updating Symfony to version 4.4 on Symfonycast

Top comments (0)