aaaa aaaa - 10 months ago 84
PHP Question

Symfony 2 ServiceNotFoundException

I am trying to use doctrine in my symfony API project, I have this controller but when it is called I get the error "ServiceNotFoundException"


namespace Cogc\EnquirerAPIBundle\Controller;

use FOS\RestBundle\Controller\FOSRestController;
use Doctrine;

class PageController extends FOSRestController
public function getPageAction($id)
return $this->container->get('doctrine.entity_manager')->getRepository('Page')->find($id);


Possibly a typo.

Check if the service exist by dumping your container service deifinition via command line as:

 php app/console container:debug

In my case the service is named as doctrine.orm.entity_manager