Flag of Ukraine
SymfonyCasts stands united with the people of Ukraine

Upgrading/Migrating from StofDoctrineExtensions

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 $10.00

With a Subscription, click any sentence in the script to jump to that part of the video!

Login Subscribe

Let's see how our deprecation todo list is looking: refresh the homepage, open the profiler and... we still have the TreeBuilder::root() deprecation coming from stof_doctrine_extension's.

You know the drill: try to upgrade this the lazy way: find the package name and copy it:

103 lines composer.json
... lines 2 - 3
"require": {
... lines 5 - 20
"stof/doctrine-extensions-bundle": "^1.3",
... lines 22 - 42
... lines 44 - 101

We're hoping a minor upgrade - maybe from 1.3 to 1.4 - will fix things. Update!

composer update stof/doctrine-extensions-bundle

And... once again... nothing happens.


Symfony 5 support was added in release v1.4.0 of stof/doctrine-extensions-bundle so you can continue using this package and skip installing antishov/doctrine-extensions-bundle fork as we do further.

Let's go hunting for answers! Google for StofDoctrineExtensionsBundle and... find its GitHub page. The first question I have is: what is the latest version? It's, oh: 1.3.0 - that's the version we're using... and it's 2 years old!

This is an example of a bundle that, at least at the time of this recording, does not yet support Symfony 5. So... what do we do? Panic! Ahhhh.

Now that we've accomplished that, I recommend looking at the package's issues and pull requests. Hopefully you will find some conversation about Symfony 5 support and, hopefully, it's something that's coming soon or you can help with.

But... in this case, as much as I like this bundle, you'll find that it's basically abandoned.

Hello fork: antishov/doctrine-extensions-bundle

That does happen sometimes. After all, most open source maintainers are volunteers. However, that digging into the pull requests would also reveal that someone in the community has done a really nice job of forking this library and creating some new releases.

Copy the library name, Google for it and... let's see... here is its GitHub page. Click to view the releases.

Basically, someone forked the library, kept all the code and release history, but started fixing things and creating new releases... including a release that adds Symfony 5 support. We're saved!

Changing to antishov/doctrine-extensions-bundle

So let's switch to use this fork. Copy the stof package name again, and remove it:

composer remove stof/doctrine-extensions-bundle

Composer removes it and then... explodes! That's ok: it was removed... but because our app, needs this library... it's temporarily not speaking to us.

Now go back to the homepage of the fork, find the composer require line, copy it, and re-install the library:

composer require antishov/doctrine-extensions-bundle

This basically gives us the same library but at a newer version. The author also created an identical recipe for this package, so even the recipe gets re-installed nicely.

Commit the files we know we want to keep:

git add composer.json composer.lock symfony.lock

Now selectively-choose the changes from the updated recipe by running:

git add -p

For bundles.php - it looks like it removed the bundle... but if you hit "y", it just moved it. A meaningless change. And next, because it re-installed the recipe, it removed our custom changes. Hit "n" to skip those.

Let's commit!

git commit -m "using doctrine extensions bundle fork"

And then, revert the changes to the config file:

git checkout .

So... that update was weird. Let's close some tabs and refresh. Yas! The deprecations jumped from 25 to 16.

We're killing it! The next deprecations are going to uncover that we also need to upgrade DoctrineBundle... from version 1 to 2 - a significant jump.

Leave a comment!

Login or Register to join the conversation
Dariia M. Avatar
Dariia M. Avatar Dariia M. | posted 3 years ago

STOF released 1.4.0 version with Symfony 5 support at March 30, 2020. Seems to work fine :)


Hey Dariia M.

Thanks for sharing, I think we can add a tip abut it!


Mouad E. Avatar
Mouad E. Avatar Mouad E. | posted 3 years ago

Hi, thanks for the hard work.

for now i found those



which one is recommended to use? because i see that all is the same, why we need 3 libraries do the same thing? after stof bundle i migrated to gedmo.


Hey Adam,

Let me to shed some light on this :) First of all, why do we have 3 libraries (actually there are more on GitHub) that do the same thing? Well, they all have similar behaviors but have different implementation. To understand the exact reasons probably better to look at library history, when it was created, why it was created. Authors might give better explanation for this :) But this question is too wide actually. Why do we have a few PHP frameworks on the market? etc. This is the same question :) Mostly, because someone tried to use one implemenation, then understood he does not like the implementation and decided he could make a better implementation. So he decided to create his own package, etc. - but this is one of many possible reasons.

Anyway, we have what we have so far. Now about those packages. gedmo/doctrine-extensions is just a PHP/Doctrine library that was ported to Symfony as a bundle thanks to StofDoctrineExtensionsBundle. unfortunately, it has a very slow support, so a guy decided to fork it and make Symfony 5 support called antishov/doctrine-extensions-bundle. As we use StofDoctrineExtensionsBundle in our project - it's easier to migrate to antishov/doctrine-extensions-bundle as it's the same project - you can see it in this video when it's ready.

About knplabs/doctrine-behaviors - this is just a concurrent project with its own implementation of similar behaviors. Lately it was pushed forward a lot, also has Symfony 5 support and a lot of good changes now. You can check the release log for more info.

But basically, it's the matter of taste.

I hope it's clearer for you now.


Cat in space

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

What PHP libraries does this tutorial use?

// composer.json
    "require": {
        "php": "^7.3.0",
        "ext-iconv": "*",
        "antishov/doctrine-extensions-bundle": "^1.4", // v1.4.2
        "aws/aws-sdk-php": "^3.87", // 3.110.11
        "composer/package-versions-deprecated": "^1.11", // 1.11.99
        "doctrine/doctrine-bundle": "^2.0", // 2.0.6
        "doctrine/doctrine-migrations-bundle": "^1.3|^2.0", // 2.1.2
        "doctrine/orm": "^2.5.11", // v2.7.2
        "doctrine/persistence": "^1.3.7", // 1.3.8
        "easycorp/easy-log-handler": "^1.0", // v1.0.9
        "http-interop/http-factory-guzzle": "^1.0", // 1.0.0
        "knplabs/knp-markdown-bundle": "^1.7", // 1.8.1
        "knplabs/knp-paginator-bundle": "^5.0", // v5.0.0
        "knplabs/knp-snappy-bundle": "^1.6", // v1.7.0
        "knplabs/knp-time-bundle": "^1.8", // v1.11.0
        "league/flysystem-aws-s3-v3": "^1.0", // 1.0.23
        "league/flysystem-cached-adapter": "^1.0", // 1.0.9
        "league/html-to-markdown": "^4.8", // 4.8.2
        "liip/imagine-bundle": "^2.1", // 2.3.0
        "nexylan/slack-bundle": "^2.1", // v2.2.1
        "oneup/flysystem-bundle": "^3.0", // 3.3.0
        "php-http/guzzle6-adapter": "^2.0", // v2.0.1
        "sensio/framework-extra-bundle": "^5.1", // v5.5.3
        "symfony/asset": "5.0.*", // v5.0.2
        "symfony/console": "5.0.*", // v5.0.2
        "symfony/dotenv": "5.0.*", // v5.0.2
        "symfony/flex": "^1.0", // v1.17.6
        "symfony/form": "5.0.*", // v5.0.2
        "symfony/framework-bundle": "5.0.*", // v5.0.2
        "symfony/mailer": "5.0.*", // v5.0.2
        "symfony/messenger": "5.0.*", // v5.0.2
        "symfony/monolog-bundle": "^3.5", // v3.5.0
        "symfony/security-bundle": "5.0.*", // v5.0.2
        "symfony/sendgrid-mailer": "5.0.*", // v5.0.2
        "symfony/serializer-pack": "^1.0", // v1.0.2
        "symfony/twig-bundle": "5.0.*", // v5.0.2
        "symfony/twig-pack": "^1.0", // v1.0.0
        "symfony/validator": "5.0.*", // v5.0.2
        "symfony/webpack-encore-bundle": "^1.4", // v1.7.2
        "symfony/yaml": "5.0.*", // v5.0.2
        "twig/cssinliner-extra": "^2.12", // v2.12.0
        "twig/extensions": "^1.5", // v1.5.4
        "twig/inky-extra": "^2.12" // v2.12.0
    "require-dev": {
        "doctrine/doctrine-fixtures-bundle": "^3.0", // 3.3.0
        "fzaninotto/faker": "^1.7", // v1.8.0
        "symfony/browser-kit": "5.0.*", // v5.0.2
        "symfony/debug-bundle": "5.0.*", // v5.0.2
        "symfony/maker-bundle": "^1.0", // v1.14.3
        "symfony/phpunit-bridge": "5.0.*", // v5.0.2
        "symfony/profiler-pack": "^1.0", // v1.0.4
        "symfony/var-dumper": "5.0.*" // v5.0.2