Buy
Buy

How to Upgrade to Symfony 2.8

Confused by the First Paragraph? https://www.youtube.com/watch?v=K7zNY0I5JNI

The Symfony Demo: example app: a project barely alive... on Symfony 2.7. Ladies and gentlemen, we can rebuild it, we have the technology. We have the capability to make the world's first Symfony 3 app. Better than it was before, stronger, faster, the 3.0 version demo app. This series is all about upgrading to Symfony 3.

Of course, the first step is actually to upgrade to Symfony 2.8. No wait! That's really cool too: because it'll give us all of the features of Symfony 3.

To get to 2.8, open the composer.json file, find the symfony/symfony line and set it to 2.8. At recording, Symfony 2.8 wasn't released yet so I'll set this to 2.8.*@BETA:

62 lines composer.json
... lines 1 - 8
"require": {
... lines 10 - 26
"symfony/symfony" : "2.8.*@BETA",
... line 28
},
... lines 30 - 62

But you - person-living-in-the-future - you should set it to 2.8.*.

Head over to the terminal and run:

composer update symfony/symfony --with-dependencies

This will download 2.8 and update any other libraries that Symfony depends on.

Yes yes, I realize that we're ignoring potential updates of all of these other bundles and libraries. But focus! Upgrade Symfony first, and then upgrade other libraries when you want to.

Changes in 2.8 (Deprecations)

Since we're just upgrading from Symfony 2.7 to 2.8, there shouldn't be any backwards compatibility breaks... though one usually sneaks in... usually with forms. While Composer is dialing out to Jordi, switch to the browser, and head to http://github.com/symfony/symfony to check out the upgrade log for 2.8 to see what has changed.

This describes things that were deprecated. Translation: these are things you'll need to upgrade before heading to 3.0... but you can safely ignore them for now. I've already covered some of these in our tutorial on What's new in Symfony 3. For example, the new way you create form types has changed quite a lot. But this isn't our concern quite yet.

Head back to the terminal to check on our update. Cool it's done! Scroll up to see that it updated to Symfony 2.8 Beta 1, and grabbed a whole bunch of other library updates related to this.

Go over to the browser and refresh our localhost homepage. That's it! We've now got the new web debug toolbar at the bottom: ooo pretty. That's your sign that you are now upgraded to 2.8!

That is the easiest step in this process... and it's also the most important because Symfony 2.8 has all the features of 3.0. So yea, woo! Next we'll upgrade to the new, fancy, Symfony 3 directory structure.

Leave a comment!

  • 2019-02-14 weaverryan

    Hey Scottie Gutman!

    Fascinating! I've never heard of this - I think you stumbled upon an edge case in Symfony's config system that probably doesn't quite work as well as it should. Here's an issue about it: https://github.com/symfony/...

    So basically, this *usually* works - the keys are all merged together just fine. The difference is that, for *most* of the config keys, there is a Configuration file that determines literally every valid key that is allowed - https://github.com/symfony/.... However, this ssl key is a bit special - you're allowed to pass *any* array with *any* keys you want - https://github.com/symfony/... - and when you have THAT situation... apparently the arrays cannot be merged unless they all have the same keys. I know - super weird.

    So, *ideally* you can work around it by, for example, setting `cafile: null` or something similar in your main config.yml... but that could have side effects. If you can't find a work around - let me know - there is *always* a work around ;).

    Cheers!

  • 2019-02-13 Scottie Gutman

    So I found the culprit. For swiftmailer my config.yml has this:


    # Swiftmailer Configuration
    swiftmailer:
    transport: "%mailer_transport%"
    host: "%mailer_host%"
    username: "%mailer_user%"
    password: "%mailer_password%"
    auth_mode: "%mailer_auth_mode%"
    port: "%mailer_port%"
    encryption: "%mailer_encryption%"
    # spool: { type: memory }
    logging: true
    stream_options:
    ssl:
    allow_self_signed: true
    verify_peer: false
    verify_peer_name: false

    but my config_dev.yml has this:


    swiftmailer:
    spool: { type: memory }
    stream_options:
    ssl:
    allow_self_signed: true
    verify_peer: false
    verify_peer_name: false
    cafile: "C:\\php7\\cacert.pem"


    Notice the extra line for the "cafile" that is not in the config.yml.

    Why should this make a difference?

  • 2019-02-13 Scottie Gutman

    Hello, After the update, Cache:clear fails with [RuntimeException] merge() expects a normalized config array. I am assuming it means that it does not like a config file. How do I find out which one?

  • 2017-10-23 Diego Aguiar

    Hmm, interesting, which version of `doctrine-bundle` are you using? Try using 1.6
    And make sure you are really running in PHP 7.1, that error is related to PHP 7.0

    Cheers

  • 2017-10-20 RAJAONA Ywoumé

    i have this error then i upgrade to symfony 2.8 when i do : composer update symfony/symfony --with-dependencies , when the vendor is installed i have this error when i refresh my broswer

  • 2017-10-20 Diego Aguiar

    Hey RAJAONA Ywoumé

    Could you tell us more information about that error.
    What were you doing when it ocurred?

    Cheers!

  • 2017-10-20 RAJAONA Ywoumé

    Fatal error: Uncaught TypeError: Return value of Doctrine\Common\Annotations\AnnotationRegistry::registerLoader() must be an instance of Doctrine\Common\Annotations\void, none returned in /home/ywoume/www/upgrade/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 117

    i use php7.1