English 中文(简体)
未找到实体类的映射文件
原标题:No mapping file found for Entity class

我对Symfony2 是个新人,我在我的项目中创建了一个实体类,但我有一个错误。我对解决方案进行了大量搜索,但找不到。这是我的控制器。

<?php
namespace IDPBundleController;

use SymfonyBundleFrameworkBundleControllerController;
use IDPBundleEntityPortfolio;

class PortfolioController extends Controller {

public function indexAction() {
    $product = $this->getDoctrine()
    ->getRepository( IDPBundle:Portfolio )
    ->find(1);
    return $this->render( IDPBundle:Portfolio:index.html.twig );
时 时

时 时

实体文件夹中的 我的组合集. php 类似

<?php

namespace IDPBundleEntity;

use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;
/**
* IDPBundleEntityPortfolio
* @ORMTable(name="pm_portfolios")
*/
class Portfolio
{
/**
 * @var integer $id
 */
private $id;

/**
 * @var integer $user_id
 */
private $user_id;

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

/**
 * @var text $description
 */
private $description;

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

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

/**
 * @var boolean $shared
 */
private $shared;

/**
 * @var integer $shared_portfolio_calls
 */
private $shared_portfolio_calls;

/**
 * @var integer $patentgroup_id
 */
private $patentgroup_id;


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

/**
 * Set user_id
 *
 * @param integer $userId
 */
public function setUserId($userId)
{
    $this->user_id = $userId;
时 时

/**
 * Get user_id
 *
 * @return integer 
 */
public function getUserId()
{
    return $this->user_id;
时 时

/**
 * Set portfolio_name
 *
 * @param string $portfolioName
 */
public function setPortfolioName($portfolioName)
{
    $this->portfolio_name = $portfolioName;
时 时

/**
 * Get portfolio_name
 *
 * @return string 
 */
public function getPortfolioName()
{
    return $this->portfolio_name;
时 时

/**
 * Set description
 *
 * @param text $description
 */
public function setDescription($description)
{
    $this->description = $description;
时 时

/**
 * Get description
 *
 * @return text 
 */
public function getDescription()
{
    return $this->description;
时 时

/**
 * Set permalink
 *
 * @param string $permalink
 */
public function setPermalink($permalink)
{
    $this->permalink = $permalink;
时 时

/**
 * Get permalink
 *
 * @return string 
 */
public function getPermalink()
{
    return $this->permalink;
时 时

/**
 * Set sharing_code
 *
 * @param string $sharingCode
 */
public function setSharingCode($sharingCode)
{
    $this->sharing_code = $sharingCode;
时 时

/**
 * Get sharing_code
 *
 * @return string 
 */
public function getSharingCode()
{
    return $this->sharing_code;
时 时

/**
 * Set shared
 *
 * @param boolean $shared
 */
public function setShared($shared)
{
    $this->shared = $shared;
时 时

/**
 * Get shared
 *
 * @return boolean 
 */
public function getShared()
{
    return $this->shared;
时 时

/**
 * Set shared_portfolio_calls
 *
 * @param integer $sharedPortfolioCalls
 */
public function setSharedPortfolioCalls($sharedPortfolioCalls)
{
    $this->shared_portfolio_calls = $sharedPortfolioCalls;
时 时

/**
 * Get shared_portfolio_calls
 *
 * @return integer 
 */
public function getSharedPortfolioCalls()
{
    return $this->shared_portfolio_calls;
时 时

/**
 * Set patentgroup_id
 *
 * @param integer $patentgroupId
 */
public function setPatentgroupId($patentgroupId)
{
    $this->patentgroup_id = $patentgroupId;
时 时

/**
 * Get patentgroup_id
 *
 * @return integer 
 */
public function getPatentgroupId()
{
    return $this->patentgroup_id;
时 时
时 时

我得到的错误是

 No mapping file found named  IDP.Bundle.Entity.Portfolio.php  for class  IDPBundleEntityPortfolio .

Am I missing anything ? Thanks?

问题回答

您需要在实体类中添加@ ORMECDY 。 请尝试 :

<?php

namespace IDPBundleEntity;

use DoctrineORMMapping as ORM;
use SymfonyComponentValidatorConstraints as Assert;

/**
* IDPBundleEntityPortfolio
*
* @ORMEntity
* @ORMTable(name="pm_portfolios")
*/
class Portfolio
{

您还需要在您的投资组合实体的每一项财产中添加ORM绘图(见