Possible Duplicate:
How can i inject dependencies to Symfony Console commands?可能重复:如何将依赖项注入Symfony控制台命令?
I want to make console application, which changes some records from the database (using Cron, every hour). How to get Doctrine ORM instance here?
我想制作控制台应用程序,它会从数据库中更改一些记录(每小时使用Cron)。如何在这里获得Doctrine ORM实例?
In casual controller, I do this:
在休闲控制器中,我这样做:
$this->getDoctrine();
1 个解决方案
#1
72
If you extend from ContainerAwareCommand
you should be able to get your service
如果您从ContainerAwareCommand扩展,您应该能够获得您的服务
$this->getContainer()->get('doctrine');
Here is similar question
这是类似的问题
#1
72
If you extend from ContainerAwareCommand
you should be able to get your service
如果您从ContainerAwareCommand扩展,您应该能够获得您的服务
$this->getContainer()->get('doctrine');
Here is similar question
这是类似的问题