I'm working on a Symfony Single Command Application. I'm using Doctrine to manage entities.
I created the entity configuration using the Symfony CLI and now I'm not sure how I can get access to the EM from within the run method.
Should I create a new subclass of SingleCommandApplication for this?
If you are truly using a Single Command Application, you'll have to configure Doctrine on your own within the
setCode()method. E.g. following these instructions.On a single command application you do not have "bundles" as such, since you are operating outside of the Framework bundle, and generally you wouldn't have access to dependency injection either.
(If you wanted DI, you'd probably have something like this while calling the
setDefaultCommand()method on the instantiatedApplicationobject, but you'd still need to instantiate the Doctrine connection "manually", even if you are doing on a different service to be injected).