Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Project Setup & The Plan

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

Hey friends! If you're like me, you probably have a Symfony 5 project - or 10 - lying around just waiting to get upgraded to Symfony 6. Well... you've come to the right place! That's exactly what we're going to do in this tutorial! But more than that! This is a particularly interesting upgrade, because it also involves updating our code to use PHP 8. And that includes a transformation from using annotations to PHP 8 attributes. I need to find my monocle, because we're getting fancy. It also includes several other PHP 8 features, which you're really going to like. Plus, for the first time, we're going to use a tool called "Rector" to automate as much of this as possible. And... because I just can't help myself, we'll discover nice new Symfony 6 features along the way.

Getting the Project Running

All right! To get this upgrade party started, you should definitely code along with me. Download the course code from this page and unzip it to find a start/ directory with the same code you see here. Follow this README.md file for all the setup goodies. I've already followed most of these steps... but I still need to build my Webpack Encore assets and start a web server. So let's do that!

Over in my terminal (this is already inside the project), run

yarn install

or

npm install

to download the Node packages. I want to get this running properly because we're going to upgrade some of our JavaScript tools a bit later.

Then run:

yarn watch

or

npm run watch

to build the frontend assets... and then watch for changes.

For the last step: open a new terminal tab and get a local web server started. I'm going to use the Symfony server like normal by running:

symfony serve -d

And... awesome! That starts a new web server at https://127.0.0.1:8000. I'll click that and say... "Hello" to Cauldron Overflow! My old friend! This is the site we've been building throughout our Symfony 5 series. And if you check its composer.json file... and look down here for Symfony stuff... whoa.. it is old. All of the main Symfony libraries are version "5.0". That was ages ago. I was so young then!

The Plan

Here's our upgrade strategy. Step one: we're going to upgrade our project to Symfony 5.4. That's safe to do because Symfony doesn't include any backwards compatibility breaks on minor version upgrade. So anytime you upgrade just this middle number - called the "minor" number, like 5.0 to 5.4 - that's always going to be safe.

Step two: once we're on Symfony 5.4, to prepare our code for Symfony 6, all we need to do is hunt down and fix all of the deprecations in our code. Once we've fixed those, it will be safe to go to Symfony 6. To find those deprecations, we're going to use a few tools, like "Rector" to upgrade parts of our code, the new recipes update system and the tried-and-true Symfony "deprecations reporting".

After all of that, once we have a Symfony 5.4 project with no deprecations... we can just "flip the switch" and upgrade to Symfony 6. Easy peasy!

And at the very end, we'll cover a few more new features that you might like. Are you ready? Great! Let's upgrade our site to Symfony 5.4 next.

Leave a comment!

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": "^8.0.2",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "babdev/pagerfanta-bundle": "^3.6", // v3.6.1
        "composer/package-versions-deprecated": "^1.11", // 1.11.99.5
        "doctrine/annotations": "^1.13", // 1.13.2
        "doctrine/dbal": "^3.3", // 3.3.5
        "doctrine/doctrine-bundle": "^2.0", // 2.6.2
        "doctrine/doctrine-migrations-bundle": "^3.2", // 3.2.2
        "doctrine/orm": "^2.0", // 2.11.2
        "knplabs/knp-markdown-bundle": "^1.8", // 1.10.0
        "knplabs/knp-time-bundle": "^1.18", // v1.18.0
        "pagerfanta/doctrine-orm-adapter": "^3.6", // v3.6.1
        "pagerfanta/twig": "^3.6", // v3.6.1
        "sensio/framework-extra-bundle": "^6.0", // v6.2.6
        "sentry/sentry-symfony": "^4.0", // 4.2.8
        "stof/doctrine-extensions-bundle": "^1.5", // v1.7.0
        "symfony/asset": "6.0.*", // v6.0.7
        "symfony/console": "6.0.*", // v6.0.7
        "symfony/dotenv": "6.0.*", // v6.0.5
        "symfony/flex": "^2.1", // v2.1.7
        "symfony/form": "6.0.*", // v6.0.7
        "symfony/framework-bundle": "6.0.*", // v6.0.7
        "symfony/mailer": "6.0.*", // v6.0.5
        "symfony/monolog-bundle": "^3.0", // v3.7.1
        "symfony/property-access": "6.0.*", // v6.0.7
        "symfony/property-info": "6.0.*", // v6.0.7
        "symfony/proxy-manager-bridge": "6.0.*", // v6.0.6
        "symfony/routing": "6.0.*", // v6.0.5
        "symfony/runtime": "6.0.*", // v6.0.7
        "symfony/security-bundle": "6.0.*", // v6.0.5
        "symfony/serializer": "6.0.*", // v6.0.7
        "symfony/stopwatch": "6.0.*", // v6.0.5
        "symfony/twig-bundle": "6.0.*", // v6.0.3
        "symfony/ux-chartjs": "^2.0", // v2.1.0
        "symfony/validator": "6.0.*", // v6.0.7
        "symfony/webpack-encore-bundle": "^1.7", // v1.14.0
        "symfony/yaml": "6.0.*", // v6.0.3
        "symfonycasts/verify-email-bundle": "^1.7", // v1.10.0
        "twig/extra-bundle": "^2.12|^3.0", // v3.3.8
        "twig/string-extra": "^3.3", // v3.3.5
        "twig/twig": "^2.12|^3.0" // v3.3.10
    },
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.4", // 3.4.1
        "phpunit/phpunit": "^9.5", // 9.5.20
        "rector/rector": "^0.12.17", // 0.12.20
        "symfony/debug-bundle": "6.0.*", // v6.0.3
        "symfony/maker-bundle": "^1.15", // v1.38.0
        "symfony/var-dumper": "6.0.*", // v6.0.6
        "symfony/web-profiler-bundle": "6.0.*", // v6.0.6
        "zenstruck/foundry": "^1.16" // v1.18.0
    }
}