Symfony 6 Certification New exam with updated questions 100% online Show your expertise

New in Symfony 2.2: Logging of deprecated calls

Warning: This post is about an unsupported Symfony version. Some of this information may be out of date. Read the most recent Symfony Docs.

The first Long Term Support version of Symfony2 will be 2.3, to be released in May 2013. In the meantime, we are in a race where we try to finish and polish everything as we won't allow BC breaks after 2.3 without a very good reason (a security issue for instance). So, since 2.0, instead of just replacing or removing existing features, we deprecate them and they will be removed in 2.3.

But how can you track those deprecated features? Of course, the CHANGELOGs and the UPGRADE file mention all the BC breaks and the deprecated features. But the code itself also contains some hints about deprecated methods and classes as they are tagged with @deprecated. But what if you miss some occurrences in your code? Will your code explode when upgrading to 2.3? The short answer is yes.

Contributed by
Colin Frei
in #6173 and #6180.

So, to provide a smoother transition, Symfony 2.2 introduces a new feature: the logging of deprecated calls. Whenever you call a deprecated method or whenever you create an instance of a deprecated class, Symfony will now log the call and alert you in the debug toolbar:

Deprecated calls logged in the web debug toolbar

Contributed by
Victor Berchet
in #6232.

That's really nice, but there is more. You can also go to the web profiler, and the log panel will tell you exactly where the call occurred:

Deprecated calls logged in the profiler

And if you have some functional tests, or just by browsing your application manually, you can automate everything by parsing the Symfony log file:

[2012-12-17 11:24:03] deprecation.WARNING: foo {
    "stack":[/* stack trace not show here */]
Help the Symfony project!

As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.


One more awesome feature. Thanks.
great idea :-)
great feature! thanx.
I think I'm gonna love this tool :)
Love it :)
Thanks Colin.

For those who ask "why -100 ?" (btw should be why '-100' ?). Twig bugs. I think Tobion has submitted a PR, I'll revisit the code.
This might be one of the best things ever!
Awesome!! +1
Nice feature !
Very nice, but usage of @deprecated annotation was not possible?

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.