Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Upgrade to Symfony 3.0?

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.

Upgrade to Symfony 3.0?

Now that we are upgraded to Symfony 2.2 it’s time to start preparing your application to work with 3.0!

On each release of Symfony, some functionality is deprecated and scheduled to be removed entirely later. For the first time, a few things have been deprecated and scheduled to be removed in Symfony 3.0.

To see them, check out the Symfony 3.0 CHANGELOG - through any of the 2.x releases, you can check out this file and find out how to be ahead of the game when it comes to future-compatability.

Routing Method and Scheme Changes

There’s not a lot in here yet, but there are a few really important things about routing! First, let’s update our route to use the _method and _scheme requirements:

fragments:
    pattern: /fragments
    defaults:
        _controller: EventBundle:NewFeatures:testFragmentsMobile
    host:    foo.%base_host%
    requirements:
        _method: GET|POST
        _scheme: https

All of this works before Symfony 2.2, and it says that this route should only match if the HTTP method is GET or POST and should force the user to use HTTPs.

As of 2.2, this syntax is deprecated, but won’t be removed until 3.0. Let’s update our routes to be Symfony3-compatible:

fragments:
    pattern: /fragments
    defaults:
        _controller: EventBundle:NewFeatures:testFragmentsMobile
    host:    foo.%base_host%
    methods: [GET, POST]
    schemes: https

Pattern to Path Routing Change

This will work today, tomorrow, and even for any Symfony3 version. Actually, there’s one more change that’s much more important than this: pattern has changed to path:

fragments:
    path: /fragments
    defaults:
        _controller: EventBundle:NewFeatures:testFragmentsMobile
    host:    foo.%base_host%
    methods: [GET, POST]
    schemes: https

This is all just a syntax change, and if you get in the habit of using the new way, you might just save yourself some heartache later when Symfony 3.0 is the greatest thing since sliced bread.

Time to go run and tell your friends that you’ve upgraded to Symfony 3.0! Ok, you haven’t actually of course, but if your friends aren’t programmers they won’t know what you’re talking about anyways.

Leave a comment!

3
Login or Register to join the conversation
Default user avatar
Default user avatar Sudhir Gupta | posted 5 years ago

hi team KNP,
I am confused to choose between symfony 2.8 or 3.0
i am going to work in large and messy project. in symfony website there is mention that support will end in july 2016 for SYM3
should i go for SYM 2.8
Others developer are saying that we should go for 2.8 bcz of the long support. i don't no which one should be opt.

Reply

Hi Sudhir!

I replied to you via email, but it's a great question, so just in case others are curious:

In short, you should (probably) use Symfony 3. But let me tell you a bit more:

1) Symfony 2.8 indeed as long term support (LTS). Yay!

2) Symfony 3.0 does not have LTS, and as you correctly stated, its support will end in July 2016. However, there are new Symfony releases every 6 months. So, Symfony 3.1 will be released in May 2016, and Symfony 3.2 in Nov 2016. Those will also *not* be LTS. The next LTS will be Symfony 3.4, release in Nov 2017. BUT, because of Symfony's backwards-compatibility promise, upgrading from 3.0 -> 3.1, and 3.1->3.2 is very easy and doesn't involve changing any of your code (you upgrade, and things just work). So, when 3.1 comes out, you can easily upgrade. When 3.2 comes out, you can easily upgrade again. It will be easy to always stay on a supported version, as long as you upgrade within 12 months.

So, why would some people recommend 2.8? If you have an application and you know that you will *not* have the time to upgrade (e.g. from 3.0->3.1, then 3.1->3.2) every 6 months, then it might be better to stay on 2.8 since it will be supported for a few years. Really, the only negative to this approach is that when 3.1 comes out, it will have new features that you will not have in 2.8. But, maybe you won't care about those features :). And if you do, you can always upgrade from 2.8 to 3.1 when you need to.

Cheers!

Reply
Default user avatar

thank a lot weaverryan.
you had nicely briefed.

however we had decide to go for 2.8 bcz of messy project. we don't want to get into trouble on last time. (last minute rush is always painful.)

But for other users, i would like to guide that go for 3.0
I had worked in both versions but personally i like 3.0. this one is much better than 2.8. (For why, users can google symfony 2.8 vs 3.0)

but unfortunately google have less article for 3.0. most of the paid version and some are not written well for beginners.

I hope i could make video article soon for beginners..

Reply
Cat in space

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

userVoice