Php Symfony2条令ORM经理命名为;“客户”;不存在

Php Symfony2条令ORM经理命名为;“客户”;不存在,php,symfony,doctrine-orm,doctrine,Php,Symfony,Doctrine Orm,Doctrine,您好,我提供了使用Symfony2文档中两个不同数据库连接的示例: 因此,Symfony没有找到客户实体管理器。 (参数定义正确) 控制器如下所示: class DefaultController extends Controller { /** * @Route("/", name="homepage") */ public function indexAction(Request $request) { $em = $this->get('doctrine')->ge

您好,我提供了使用Symfony2文档中两个不同数据库连接的示例: 因此,Symfony没有找到客户实体管理器。 (参数定义正确)

控制器如下所示:

class DefaultController extends Controller
{
/**
 * @Route("/", name="homepage")
 */
public function indexAction(Request $request)
{
    $em = $this->get('doctrine')->getManager();
    $em = $this->get('doctrine')->getManager('default');
    $em = $this->get('doctrine.orm.default_entity_manager');

    // Both of these return the "customer" entity manager
    $customerEm = $this->get('doctrine')->getManager('customer');
    $customerEm = $this->get('doctrine.orm.customer_entity_manager');
    return $this->render('default/index.html.twig', array(
        'base_dir' => realpath($this->container->getParameter('kernel.root_dir').'/..'),
    ));
}
我应该获得Customer实体管理器,但是Symfony在消息中抛出了一个无效参数异常

[2015-10-19 23:19:18] request.CRITICAL: Uncaught PHP Exception 
InvalidArgumentException: "Doctrine ORM Manager named "customer" does 
not exist." at /srv/www/htdocs/symfony/my_project_name/app/cache
/prod/classes.php line 7344 {"exception":"[object] 
(InvalidArgumentException(code: 0): Doctrine ORM Manager named 
\"customer\" does not exist. at /srv/www/htdocs/symfony/my_project_name
/app/cache/prod/classes.php:7344)"} []

我用php app/console cache:clear清理了缓存,但这没有帮助。

首先,我认为,在控制器中声明一个实体管理器就足够了:

/ *** /   
public function indexAction(Request $request)
{
    $em = $this->get('doctrine')->getManager('default');

    $customerEm = $this->get('doctrine')->getManager('customer');

    / *** /
}

其次,您是否确定可以在映射配置中声明相同的捆绑包(
AppBundle:~
,在本例中)?

Artamiel在一条评论中给出了正确的答案:

cache:clear默认情况下清除dev环境,但是查看错误日志,您会在prod环境中收到错误。要清除生产环境中的缓存,请添加-e prod标志,如以下缓存:清除-e prod并刷新页面


cache:clear
默认情况下清除
dev
环境,但查看错误日志,您会在
prod
环境中收到错误。要清除生产环境中的缓存,请添加
-e prod
标志,如
缓存:清除-e prod
并刷新页面。
/ *** /   
public function indexAction(Request $request)
{
    $em = $this->get('doctrine')->getManager('default');

    $customerEm = $this->get('doctrine')->getManager('customer');

    / *** /
}