Upgrading to Symfony 3.3!

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.

Yo peeps! Wow, Symfony 3.3! Actually, that version number sounds kinda boring. I mean, 3.3? Really? I expect cool stuff to happen in version 3.3?

Well..... normally I'd agree! But Symfony 3.3 is special: it has some big, awesome, exciting, dinosauric changes to how you configure services. And that's why we made this crazy tutorial in the first place: to take those head on.

If you're not already comfortable with how services work in Symfony, stop, drop and roll... and go watch our Symfony Fundamentals course. Then come back.

Symfony's Backwards-Compatibility Awesomeness Promise

So, how can we upgrade to Symfony 3.3? I have no idea. No, no, no - upgrading Symfony is always boring and simple. That's because of Symfony's backwards compatibility promise: we do not break things when you upgrade a minor version, like 3.2 to 3.3. It's Symfony's secret super power. I will show you how to upgrade, but it's easy.

As always, you should totally bake cookies while watching this tutorial... and also, code along with me! Click download on this page and unzip the file. Inside, you'll find a start/ directory with the same code you see here. Open the README.md file to find poetic prose... which doubles as setup instructions.


Time to upgrade! Open up composer.json:

68 lines composer.json
... lines 2 - 15
"require": {
... line 17
"symfony/symfony": "3.1.*",
... lines 19 - 30
... lines 32 - 66

This is actually a Symfony 3.1 project, but that's no problem. I'll change the version to 3.3.0-RC1 because Symfony 3.3 has not been released yet at the time of this recording. You should use 3.3.*:

68 lines composer.json
... lines 2 - 15
"require": {
... line 17
"symfony/symfony": "3.3.0-RC1",
... lines 19 - 30
... lines 32 - 66

By the way, we could update other packages too, but that's optional. Often, I'll visit the Symfony Standard Edition, make sure I'm on the correct branch, and see what versions it has in its composer.json file.

For now, we'll just change the Symfony version. To upgrade, find your favorite terminal, move into the project, and run:

composer update

This will update all of your packages to the latest versions allowed in composer.json. You could also run composer update symfony/symfony to only update that package.

Then.... we wait! While Jordi and the Packagists work on our new version.

Removing trusted_proxies

It downloads the new version then... woh! An error! Occasionally, if we have a really good reason, Symfony will change something that will break your app on upgrade... but only in a huge, obvious and unavoidable way:


The "framework.trusted_proxies" configuration key has been removed in Symfony 3.3. Use the Request::setTrustedProxies() method in your front controller instead.

This says that a framework.trusted_proxies configuration was removed. Open up app/config/config.yml: there it is! Just take that out:

... lines 1 - 11
... lines 13 - 26
trusted_hosts: ~
... lines 29 - 80

The option was removed for security reasons. If you did have a value there, check out the docs to see the replacement.

Ok, even though composer update exploded, it did update our composer.lock file and download the new version. Just to be sure, I'll run composer install to make sure everything is happy:

composer install


Enabling the WebServerBundle

Ok, start the built-in web server:

php bin/console server:run


There are no commands defined in the "server" namespace

What happened to server:run? Well actually, Symfony is becoming more and more decoupled. That command now lives in its own bundle. Open app/AppKernel.php. And in the dev environment only, add $bundles[] = new WebServerBundle():

... lines 1 - 2
use Symfony\Bundle\WebServerBundle\WebServerBundle;
... lines 4 - 6
class AppKernel extends Kernel
public function registerBundles()
... lines 11 - 27
if (in_array($this->getEnvironment(), array('dev', 'test'), true)) {
... lines 29 - 33
$bundles[] = new WebServerBundle();
... lines 36 - 37
... lines 39 - 58

That bundle still comes with the symfony/symfony package, but it wasn't enabled in our project. A new Symfony 3.3 project already has this line.

Flip back to your terminal and try again:

php bin/console server:run

Got it! Find your browser and open up http://localhost:8000 to find the famous Aquanaut project that we've been working on in this Symfony series.

Okay, we're set up and we are on Symfony 3.3. But we are not yet using any of the cool, new dependency injection features. Let's fix that!

Leave a comment!

  • 2018-09-25 Victor Bocharsky

    Hey Claire,

    Oh, looks like in this upgrade you changed your encoder algorithm, see "security.encoders.UserInterface.algorithm" in your app/config/security.yml. You can't just change it because all old passwords will be invalid anymore as they will be checked with a new algorithm. Revert back the original value and it should work for old passwords after upgrade


  • 2018-09-25 Claire Smith

    Hi :)
    I was wondering if you could point me in the right direction with a problem I'm having. I've upgraded to 3.4 wooo. However registered users from my 2.8 application can't login but if i create a new user and login it works fine. Any hints/tip ?


  • 2018-06-25 Victor Bocharsky

    Hey Stan,

    We suppose our users download the start code and recommend this way to code with us, but it may be useful for someone, thanks for sharing this little-known fact about Symfony web server.


  • 2018-06-24 Stan

    If your application's document root differs from the standard directory layout, you have to pass the correct location using the --docroot option:

    php bin/console server:start --docroot=public_html
  • 2017-12-28 Victor Bocharsky

    Hey Scott,

    Sometimes upgrading could be tricky, thanks for sharing your solution with others!


  • 2017-12-27 Skylar Scotlynn Gutman

    I just wanted to share a problem and fix. I am upgrading from 3.1 to 3.3 and got an error during composer upgrade:

    CSRF protection needs sessions to be enabled.

    So I needed to add "session: ~" to the framework section in config.yml and it fixed the problem

  • 2017-08-10 Diego Aguiar

    Hey Nina

    There are two options:
    - You could upgrade your PHP version to 7.1 or higher (Since you already have 7.0, this would be easy)
    - Or you could find an older release for "ocramius/proxy-manager" that fits your settings and don't break the app

    Have a nice day!

  • 2017-08-10 Nina

    I want look result of this course and install "finish" code
    but I have error in cmd:

    > composer install
    Loading composer repositories with package information
    Installing dependencies (including require-dev) from lock file
    Your requirements could not be resolved to an installable set of packages.

    Problem 1
    - Installation request for ocramius/proxy-manager 2.1.1 -> satisfiable by ocramius/proxy-manager[2.1.1].
    - ocramius/proxy-manager 2.1.1 requires php ^7.1.0 -> your PHP version (7.0.14) does not satisfy that requirement.
    Problem 2
    - ocramius/proxy-manager 2.1.1 requires php ^7.1.0 -> your PHP version (7.0.14) does not satisfy that requirement.
    - doctrine/migrations v1.5.0 requires ocramius/proxy-manager ^1.0|^2.0 -> satisfiable by ocramius/proxy-manager[2.1.1].
    - Installation request for doctrine/migrations v1.5.0 -> satisfiable by doctrine/migrations[v1.5.0].

    If I install "start" everything ok.

    I use OpenServer and
    in the Settings - PHP-7.1-x64, Apache-PHP-7-x64
    How can I to fix this problem?

  • 2017-06-12 Victor Bocharsky

    Hey Vlad,

    The "trusted_proxies" BC break was mitigated in Symfony 3.3.1 - check the https://github.com/symfony/... . It means, that now it just trigger deprecated error, but it will fail in Symfony 4.0. So if you don't use trusted_proxies in your app - you better remove it.


  • 2017-06-09 Vlad

    I am using Symfony 3.3.2 and I ain't getting no error for

    trusted_proxies: ~

    Should I still remove it, or keep it?