How to Upgrade Symfony 2.8 to 3.4

Are you Symfony programmer? Do you work on a successful project? Then upgrading the Symfony project is a work you can't avoid. Almost a year ago I wrote about Five and Half Steps to Migrate from Symfony 2.8 LTS to Symfony 3.4 LTS in Real PRs.

Now it's much easier to jump from one LTS to another - with instant upgrades.

Recently, more and more issues pop-up at Symfony repository asking for automated upgrade:

I'm happy Symfony core team is supporting generic solution to all PHP-code upgrades ↓

Upgrade Symfony... and PHP

To make a bad situation more complicated, this upgrade is also related to upgrading of PHP - Symfony 3.4 requires PHP 5.5.

I wrote about PHP upgrades before, but the main away is to upgrade one minor version at once:

If you split each of these lines into standalone pull-requests, you're the best!

Forget UPGRADE.md

You probably know I work almost part-time on the Rector project. I gather feedback from conferences and meetups all over Europe and try to make Rector better every day. Recently he also migrated between 2 PHP frameworks, because why not?

The PHP community gives me really positive vibes about going the right direction. That helps me to make PHP and Symfony sets more and more complete:

How to Upgrade then?

All you need to do to upgrade your PHP code is to install Rector and run particular upgrades.

Do you want to upgrade from Symfony 2.8 to 3.4?

composer require rector/rector --dev
vendor/bin/rector process app src --level symfony28
vendor/bin/rector process app src --level symfony30
vendor/bin/rector process app src --level symfony31
vendor/bin/rector process app src --level symfony32
vendor/bin/rector process app src --level symfony33
vendor/bin/rector process app src --level symfony34

You still need to upgrade YAML files, but then you're ready to go.

Are you stuck on old PHP 5.3? Rector got you covered:

vendor/bin/rector process app src --level php53
vendor/bin/rector process app src --level php54
vendor/bin/rector process app src --level php55

Awesome Symfony 3.3+ Dependency Injection

Upgrade to Symfony 3.3 shrunk my configs to 1/5 of its original size. That's the #1 reason you want to upgrade. If you don't know what I'm talking about, check the diff post about those features. But wait, don't do it manually! This tool converts it all for you.


And that's how we upgrade in 2019 :)

Happy coding!