Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

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!

What PHP libraries does this tutorial use?

// composer.json
    "require": {
        "php": ">=5.5.9",
        "symfony/symfony": "3.3.0-RC1", // v3.3.0-RC1
        "doctrine/orm": "^2.5", // 2.7.5
        "doctrine/doctrine-bundle": "^1.6", // 1.10.3
        "doctrine/doctrine-cache-bundle": "^1.2", // 1.3.5
        "symfony/swiftmailer-bundle": "^2.3", // v2.6.7
        "symfony/monolog-bundle": "^3.1", // v3.2.0
        "symfony/polyfill-apcu": "^1.0", // v1.23.0
        "sensio/distribution-bundle": "^5.0", // v5.0.25
        "sensio/framework-extra-bundle": "^3.0.2", // v3.0.29
        "incenteev/composer-parameter-handler": "^2.0", // v2.1.4
        "composer/package-versions-deprecated": "^1.11", //
        "knplabs/knp-markdown-bundle": "^1.4", // 1.7.1
        "doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.2
        "stof/doctrine-extensions-bundle": "^1.2" // v1.3.0
    "require-dev": {
        "sensio/generator-bundle": "^3.0", // v3.1.7
        "symfony/phpunit-bridge": "^3.0", // v3.4.47
        "nelmio/alice": "^2.1", // v2.3.6
        "doctrine/doctrine-fixtures-bundle": "^2.3" // v2.4.1