我是新加入symfony2的,这里有一个大问题,当我试图为一个实体保存一些数据时,我得到了这个错误
没有为类“MyBundle\Entity\Review”找到名为“MyBundle.Entity.Review.php”的映射文件
我已经阅读了与这个问题有关的所有答案,但我无法找到解决办法。拜托你能帮帮我吗?
这是我的实体代码。
<?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;
}}
这是我的控制器
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实体。如果你有恩蒂 领带或映射文件,您应该检查您的映射配置的错误。
谢谢
发布于 2017-11-13 03:14:24
没有为类MyyBundle\Entity\Review找到名为“MyBundle.Entity.Review.php”的映射文件
根据这个错误。当然,应该有一个进口相关的问题。因为,您的类在MyBundle中。应用程序正在搜索MyyBundle(在你的“我”中有两个'y's )。检查包名,然后再导入行。
https://stackoverflow.com/questions/47256542
复制相似问题