Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Deprecation Fixing Tools

Keep on Learning!

If you liked what you've learned so far, dive in!
Subscribe to get access to this tutorial plus
video, code and script downloads.

Start your All-Access Pass
Buy just this tutorial for $5.00


The video for this tutorial will be ready very soon!

Ideally, your outside bundles are no longer triggering deprecated warnings. Now it's time to update our code for Symfony 3. This means finding deprecation warnings, fixing them everywhere you can think of, and, well, repeating! It's pretty simple, but sometimes the true source of a deprecation can be tricky to find.

Symfony Upgrade Fixer

Fortunately, there are 2 tools to help us. Google for Symfony Upgrade Fixer. This is a sweet tool made by my good friend Saša. It tries to find deprecated code and fix it for you. How nice!? It only supports a few things, but it aims to fix the most annoying ones, like form changes.

Copy the wget line and paste it into your command line. Or just use that URL to download the file manually. Copy the second permissions line to make that file executable. Cool! Now we have a symfony-upgrade-fixer utility! Run it!


And then actually use it with fix and then . to fix this directory:

symfony-upgrade-fixer fix .

Behind the scenes, that's snooping through your project and writing new code for you. Ding! It fixed two form classes:

... lines 1 - 25
class PostType extends AbstractType
... lines 28 - 30
public function buildForm(FormBuilderInterface $builder, array $options)
... lines 33 - 42
... lines 44 - 47
->add('summary', TextareaType::class, array('label' => 'label.summary'))
->add('content', TextareaType::class, array(
... lines 50 - 51
->add('authorEmail', EmailType::class, array('label' => 'label.author_email'))
... lines 54 - 55
... lines 59 - 78

... lines 1 - 27
class DateTimePickerType extends AbstractType
... lines 30 - 61
public function getParent()
return DateTimeType::class;
... lines 66 - 73

By using git diff, I can see that it updated to the new TextareaType::class format. If you have a lot of forms, this is awesome.

Symfony Deprecation Detector

This tool caught a few things, but there's a lot more. So... let's try another tool! Google for Symfony Deprecation Detector. This tool doesn't fix your project, but it detects more things than the first one.

Copy the clone command and run it in the terminal:

cd any/path
git clone git@github.com:sensiolabs-de/deprecation-detector.git

Move into the directory and install the composer libraries:

cd deprecation-detector
composer install

This will give us a new binary that we can use on our project. Switch back into the directory of our project, then run the bin/deprecation-detector command from that project:


Boom! This correctly sees that 3 form types still have a getName() method, which they should not have anymore. Go into AppBundle/Form, open up each form type, and remove the getName() method from the bottom.

Perfect! Try the command again:


No violations! I wish this meant that you had no more deprecated features, but it's an imperfect tool. We need to hunt for the last few deprecations.

Leave a comment!

Login or Register to join the conversation
Default user avatar
Default user avatar ypereirareis | posted 5 years ago

Hi !

I created two docker images to run those tools, really usefull and easy to use on Symfony projects.



1 Reply
Default user avatar

If I try cloning the deprecation-detector, I get "Permission denied (publickey). Is there another way to get this?
Edit: Did it now with the phar.

Victor Avatar Victor | SFCASTS | kruben | posted 5 years ago | edited

Hey kruben ,

It's due to the SSH URL, have you logged in into your GitHub account? Anyway, HTTPS URL will work for you:

git clone https://github.com/sensiolabs-de/deprecation-detector.git

Let me know if it helps.

P.S. You can switch between SSH and HTTPS links on a GitHub project page when clicking on "Clone or download" button.


1 Reply
Default user avatar
Default user avatar DevDonkey | posted 5 years ago

Just a note to anyone using the symfony upgrade fixer, it doesn't always detect and fix 'text, entity, date, choice' form-field types.

It also has a habit of changing the use statement order of files that its not touched in any way. So if you have a touchy tech-lead and your using VCS it'll look like you've touched more files than you have.

This is just a note to suggest that the tools isn't followed blindly.

These issues have been noted to the author on the git repo.

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