I created a custom command:
class CrawlCommand extends ContainerAwareCommand{
protected function configure(){
$this->setName('crawler:crawl')
->setDescription('Command for crawling content');
}
protected function execute(InputInterface $input, OutputInterface $output){
$msg = 'hello';
$output->writeln($msg);
}
}
Tell me please, how can I do an action in execute function? Action calls CrawlerBundle:Index:index. Without services, just run action like browser.
If you want invoke action directly from command – that’s mean it’s something wrong. In controller you should implement as less logic as you can, you should create service and put logic there.
There are several reasons for that, eg. in that way unit testing is easier and you have much more clear and legible code. In addition use service is so simple in your CrawlCommand case.