我试图在我的 symfony API 项目中使用学说,我有这个 Controller ,但是当它被调用时,我收到错误“ServiceNotFoundException”
<?php
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);
}
}
最佳答案
可能是笔误。
通过命令行转储容器服务定义来检查服务是否存在:
php app/console container:debug
在我的例子中,该服务被命名为
doctrine.orm.entity_manager
关于php - Symfony 2 ServiceNotFoundException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27967312/