You need to extends ContainerAwareCommand
to have access to $this->getContainer()
namespace xxx\WebBundle\Command;
//Don't forget the use
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
class GreetCommand extends ContainerAwareCommand {
protected function configure() {}
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->getContainer()->get('doctrine')->getManager();
$em->getRepository('xxxWebBundle:Wishlist')->findAll();
// $output->writeln($text);
}
}