简体   繁体   English

类不存在symfony

[英]Class does not exist symfony

I'm having a problem recovering my entities, the entities are in the AppBundle / Entity folder, but symfony can not find it ... 我在恢复实体时遇到问题,实体位于AppBundle / Entity文件夹中,但是symfony找不到它...

Here is the error: Class 'Product' does not exist 这是错误: 类“产品”不存在

Here is the function myManager () present in a controller 这是控制器中存在的函数myManager()

public function myManager(){
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration(array(__DIR__."/AppBundle/Entity"), $isDevMode);

// database configuration parameters
        $conn = array(
            'dbname' => 'teste',
            'user' => 'root',
            'password' => '',
            'host' => '127.0.0.1',
            'driver' => 'pdo_mysql',
        );

$entityManager = EntityManager::create($conn, $config);
return $entityManager;
}

the function testAction () that calls the manager and tries to load the Product entity 函数testAction()调用管理器并尝试加载Product实体

public function testAction(){
    $em = $this->myManager()->getRepository('Product');
    return $this->render('toto.html.twig');
}

link of documentation : Doctrine 文档链接: 学说

您需要使用正确的符号来引用您的实体:

$manager->getRepository('MyBundleName:Product')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM