Getting Doctrine for a Symfony console command -
how instance of doctrine symfony console command app? need run tasks via cron job , need access database , send emails too.
your command must extends symfony\bundle\frameworkbundle\command\containerawarecommand
class.
then :
$em = $this->getcontainer()->get('doctrine')->getmanager();
Comments
Post a Comment