Inspire you to expand the doctrine:
The DoctrineExtensions library contains some annotation classes. But since these annotations mean nothing to the core of the Doctrine, it is also an extension that is responsible for interpreting them. To do this, it uses some listeners that must be registered with the Doctrine event manager.
In Symfony, you can declare services with doctrine.event_listener (or doctrine.event_subscriber for event subscribers), so the Doctrine package will find them and register them for you. The StofDoctrineExtensionsBundle is primarily aimed at automating the registration of this part of the registration of event listeners.
In any case, when you think about the extension of the Doctrine, since it can be used without Symfony, prefer to divide your work into two parts: one is the extension of the doctrine, the other is the glue between this extension and Symfony and is called a package.
source share