首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >没有为类MyyBundle\Entity\Review找到名为“MyBundle.Entity.Review.php”的映射文件

没有为类MyyBundle\Entity\Review找到名为“MyBundle.Entity.Review.php”的映射文件
EN

Stack Overflow用户
提问于 2017-11-13 03:08:06
回答 1查看 101关注 0票数 0

我是新加入symfony2的,这里有一个大问题,当我试图为一个实体保存一些数据时,我得到了这个错误

没有为类“MyBundle\Entity\Review”找到名为“MyBundle.Entity.Review.php”的映射文件

我已经阅读了与这个问题有关的所有答案,但我无法找到解决办法。拜托你能帮帮我吗?

这是我的实体代码。

代码语言:javascript
复制
<?php

namespace MyBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * Review
 */
class Review
{
/**
 * @var int
 */
private $id;

/**
 * @var string
 */
private $content;

/**
 * @var string
 */
private $score;

/**
 * @var int
 */
private $total;


/**
 * Get id
 *
 * @return integer 
 */
public function getId()
{
    return $this->id;
}

/**
 * Set content
 *
 * @param string $content
 * @return Review
 */
public function setContent($content)
{
    $this->content = $content;

    return $this;
}

/**
 * Get content
 *
 * @return string 
 */
public function getContent()
{
    return $this->content;
}

/**
 * Set score
 *
 * @param string $score
 * @return Review
 */
public function setScore($score)
{
    $this->score = $score;

    return $this;
}

/**
 * Get score
 *
 * @return string 
 */
public function getScore()
{
    return $this->score;
}

/**
 * Set total
 *
 * @param integer $total
 * @return Review
 */
public function setTotal($total)
{
    $this->total = $total;

    return $this;
}

/**
 * Get total
 *
 * @return integer 
 */
public function getTotal()
{
    return $this->total;
}

}

这是我的控制器

代码语言:javascript
复制
public function saveReviewAction() { 
$request = Request::createFromGlobals();
$request->getPathInfo();
$method = $request->getMethod();

$em = $this->getDoctrine()->getManager();

$review = new Review();
$review->setContent('CONTENT');

// tells Doctrine you want to (eventually) save the Review (no queries yet)
$em->persist($review);

// actually executes the queries (i.e. the INSERT query)
$em->flush();

  return new JsonResponse(array('msg' => 'Json','method' => $review->getContent()));

}

如果我尝试了php应用程序/控制台原则:映射:我得到的信息:

异常 根据当前配置,您没有任何映射的Doctrine实体。如果你有恩蒂 领带或映射文件,您应该检查您的映射配置的错误。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2017-11-13 03:14:24

没有为类MyyBundle\Entity\Review找到名为“MyBundle.Entity.Review.php”的映射文件

根据这个错误。当然,应该有一个进口相关的问题。因为,您的类在MyBundle中。应用程序正在搜索MyyBundle(在你的“我”中有两个'y's )。检查包名,然后再导入行。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47256542

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档