【问题标题】:Symfony 2 ServiceNotFoundExceptionSymfony 2 ServiceNotFoundException
【发布时间】:2015-03-14 01:48:19
【问题描述】:

我试图在我的 symfony API 项目中使用学说,我有这个控制器,但是当它被调用时,我收到错误“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 symfony doctrine-orm namespaces


    【解决方案1】:

    可能是笔误。

    通过命令行转储您的容器服务定义来检查服务是否存在:

     php app/console container:debug
    

    在我的例子中,服务被命名为doctrine.orm.entity_manager

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-17
      • 2018-02-15
      相关资源
      最近更新 更多