Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Upgrade Outdated Libraries!

Keep on Learning!

If you liked what you've learned so far, dive in!
Subscribe to get access to this tutorial plus
video, code and script downloads.

Start your All-Access Pass
Buy just this tutorial for $5.00

If you did you homework, then by now, you've gone through your entire site and updated your code to remove all of the deprecation warnings.

Upgrading Offending Libraries/Bundles!

Except for the ones that you can't fix, because they're not coming from your code. It's pretty likely that you have a group of external libraries and bundles that are also causing deprecation warnings.

In our app, we have this exact problem, with AsseticBundle. So before we upgrade to Symfony 3, we need to upgrade to a new version of that library that does not use old code.

No problem! Google for AsseticBundle. I'll click into the link on Packagist. I'm looking here to find the latest released version of Packagist, which right now, is 2.8.0. If we update to that, those deprecation warnings will hopefully go away.

Open up composer.json:

66 lines composer.json
... lines 2 - 12
"require": {
... lines 14 - 27
"symfony/assetic-bundle" : "~2.6",
... lines 29 - 32
... lines 34 - 64

Our version is ~2.6, but my PhpStorm Composer plugin tells me that we actually have 2.7.1. Let's require 2.8.0 by changing this to ^2.8:

66 lines composer.json
... lines 2 - 12
"require": {
... lines 14 - 27
"symfony/assetic-bundle" : "~2.8",
... lines 29 - 32
... lines 34 - 64

The ^ symbol is the new hipster way to describe your version constraints - it basically allows 2.8 and higher, but not some future 3.0 version of AsseticBundle.

Next, copy the library name - symfony/assetic-bundle. Since we only want to upgrade this library right now, find your terminal and run:

composer update symfony/assetic-bundle

What Version to Choose?

In general, if a library is giving you deprecation warnings like this one, you do need to upgrade it, but you may not need to upgrade it to the absolute latest version. If you want to be a bit more conservative, you can dig into the release notes of a library to find the first version number that is Symfony 3 compatible. It's more work, but might mean less QA time than upgrading a library many versions all at once.

Hello AsseticBundle 2.8.0! Oh, and see those messages from Composer? That's another usage of deprecations in action: some of our code is using some deprecated functionality in Composer itself. Those will probably go away when we upgrade Symfony. But, either way, it's not important right now.

Let's check in on our deprecations: refresh the page. Yes! 33 deprecations down to one. And don't worry about that last deprecation - it's really specific to this project - so I'm not going to take time to fix it.

Ok, we've now upgraded all outside libraries that were not Symfony 3 compatible and our deprecation warnings are gone. We are ready.

Leave a comment!

Login or Register to join the conversation
Cat in space

"Houston: no signs of life"
Start the conversation!

What PHP libraries does this tutorial use?

// composer.json
    "require": {
        "php": ">=5.3.9",
        "ext-pdo_sqlite": "*",
        "doctrine/doctrine-bundle": "~1.5", // 1.6.3
        "doctrine/doctrine-fixtures-bundle": "~2.2", // 2.3.0
        "doctrine/orm": "~2.4", // v2.5.4
        "erusev/parsedown": "~1.5", // 1.6.0
        "ezyang/htmlpurifier": "~4.7", // v4.7.0
        "incenteev/composer-parameter-handler": "~2.1", // v2.1.2
        "ircmaxell/password-compat": "~1.0", // v1.0.4
        "knplabs/knp-paginator-bundle": "~2.4", // 2.5.3
        "leafo/scssphp": "~0.1.5", // v0.1.10
        "patchwork/jsqueeze": "~1.0", // v1.0.7
        "sensio/distribution-bundle": "^5.0", // v5.0.7
        "sensio/framework-extra-bundle": "~3.0", // v3.0.16
        "symfony/assetic-bundle": "~2.8", // v2.8.0
        "symfony/monolog-bundle": "~2.7", // 2.11.1
        "symfony/swiftmailer-bundle": "~2.3", // v2.3.11
        "symfony/symfony": "3.0.*", // v3.0.9
        "twig/extensions": "~1.2" // v1.3.0
    "require-dev": {
        "sensio/generator-bundle": "^3.0" // v3.0.7