Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

How to Upgrade to Symfony 2.8

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.

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!

Login or Register to join the conversation
Christopher M. Avatar
Christopher M. Avatar Christopher M. | posted 4 years ago


I am getting this first error. I am trying to update my current symfony app 2.6 to 2.8 (dont judge me! lol)

> Sensio\Bundle\DistributionBundle\Composer\ScriptHandler::buildBootstrap
Cannot load Zend OPcache - it was already loaded


Hi Christopher M.

Which php version do you use and have you enabled opcache extension?


Christopher M. Avatar
Christopher M. Avatar Christopher M. | sadikoff | posted 4 years ago

I am currently using php 7.1 and I don’t think I have enable opcache extension


Hey Christopher M.

Sorry for late answer, could you please provide more info, like output of php -v
And check for loaded extension, probably there is some php misconfiguration.


Christopher M. Avatar
Christopher M. Avatar Christopher M. | sadikoff | posted 4 years ago

I was able to move from that error, but i am not getting this.

symfony FatalThrowableError in app_dev.php line 25:


Hey Christopher M.

I left you some questions in your other thread


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?


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

# Swiftmailer Configuration
    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
            allow_self_signed: true
            verify_peer: false
            verify_peer_name: false```

but my config_dev.yml has this:


spool:     { type: memory }
        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?

Hey Skylar!

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/symfony/issues/17436

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/swiftmailer-bundle/blob/master/DependencyInjection/Configuration.php. However, this ssl key is a bit special - you're allowed to pass any array with any keys you want - https://github.com/symfony/swiftmailer-bundle/blob/a9b8d20b86eda7c52f6b8b5c2f7877dec9f013e4/DependencyInjection/Configuration.php#L103-L105 - 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 ;).


Rajaona F. Avatar
Rajaona F. Avatar Rajaona F. | posted 5 years ago

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


Hey Rajaona F.

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


Rajaona F. Avatar

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


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


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