【发布时间】:2014-02-21 21:09:10
【问题描述】:
我确实有一个非常奇怪的问题,并搜索并尝试了不同的方法。正如我的标题所述,我的实体(包括所有实体!)无法正常工作 - 意味着它们无法映射。
我会很快进入重点:
扩展数组
Array ( [0] => Core [1] => date [2] => ereg [3] => libxml [4] => openssl [5] => pcre [6] => sqlite3 [7] => zlib [8] => bcmath [9] => bz2 [10] => calendar [11] => ctype [12] => curl [13] => dba [14] => dom [15] => hash [16] => fileinfo [17] => filter [18] => ftp [19] => gd [20] => gettext [21] => gmp [22] => SPL [23] => iconv [24] => session [25] => intl [26] => json [27] => ldap [28] => mbstring [29] => mcrypt [30] => mssql [31] => mysql [32] => standard [33] => PDO [34] => pdo_dblib [35] => mysqlnd [36] => pdo_sqlite [37] => pgsql [38] => apc [39] => posix [40] => Reflection [41] => imap [42] => shmop [43] => SimpleXML [44] => snmp [45] => soap [46] => sockets [47] => pdo_mysql [48] => exif [49] => sysvmsg [50] => sysvsem [51] => sysvshm [52] => tidy [53] => tokenizer [54] => wddx [55] => xml [56] => xmlreader [57] => xmlrpc [58] => xmlwriter [59] => xsl [60] => zip [61] => mysqli [62] => apache2handler [63] => Phar [64] => mhash )
到目前为止,我想出了并尝试修复:
- APC 开启(没有 eAcc,这主要是导致问题的原因)REF:("Class XXX is not a valid entity or mapped super class" after moving the class in the filesystem)
- 删除资源中的Doctrine文件夹,清除缓存。没有成功。
- 为配置 ORM 的实体添加了完整的命名空间 // 更改:“company”到“x/basebundle/entity/company”不起作用,因此恢复了更改。
- 我不使用注释,我使用 yml。
- 自动映射是真的!
Resources/Config/Doctrine/Websites.orm.yml 将实体类作为第一个参数:
Brenne\BaseBundle\Entity\Website:
type: entity
table: website
repositoryClass: Brenne\BaseBundle\Repository\WebsiteRepository
id:
id:
type: integer
generator: { strategy: AUTO }
fields:
name:
type: string
length: 110
nullable: true
url:
type: string
length: 255
nullable: true
logo:
type: string
length: 255
nullable: true
description:
type: text
oneToMany:
assignedPing:
targetEntity: ping
mappedBy: website
manyToOne:
company:
targetEntity: Company
inversedBy: website
/Entity/Websites.orm.yml 将实体类作为第一个参数:
<?php
namespace Brenne\BaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Website
*/
class Website
{
/**
* @var integer
*/
private $id;
/**
* @var string
*/
private $name;
/**
* @var string
*/
private $url;
/**
* @var string
*/
private $logo;
/**
* @var string
*/
private $description;
/**
* @var \Doctrine\Common\Collections\Collection
*/
private $assignedPing;
/**
* @var \Brenne\BaseBundle\Entity\Company
*/
private $company;
/**
* Constructor
*/
public function __construct()
{
$this->assignedPing = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Website
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set url
*
* @param string $url
* @return Website
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* Get url
*
* @return string
*/
public function getUrl()
{
return $this->url;
}
/**
* Set logo
*
* @param string $logo
* @return Website
*/
public function setLogo($logo)
{
$this->logo = $logo;
return $this;
}
/**
* Get logo
*
* @return string
*/
public function getLogo()
{
return $this->logo;
}
/**
* Set description
*
* @param string $description
* @return Website
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* Get description
*
* @return string
*/
public function getDescription()
{
return $this->description;
}
/**
* Add assignedPing
*
* @param \Brenne\BaseBundle\Entity\ping $assignedPing
* @return Website
*/
public function addAssignedPing(\Brenne\BaseBundle\Entity\ping $assignedPing)
{
$this->assignedPing[] = $assignedPing;
return $this;
}
/**
* Remove assignedPing
*
* @param \Brenne\BaseBundle\Entity\ping $assignedPing
*/
public function removeAssignedPing(\Brenne\BaseBundle\Entity\ping $assignedPing)
{
$this->assignedPing->removeElement($assignedPing);
}
/**
* Get assignedPing
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getAssignedPing()
{
return $this->assignedPing;
}
/**
* Set company
*
* @param \Brenne\BaseBundle\Entity\Company $company
* @return Website
*/
public function setCompany(\Brenne\BaseBundle\Entity\Company $company = null)
{
$this->company = $company;
return $this;
}
/**
* Get company
*
* @return \Brenne\BaseBundle\Entity\Company
*/
public function getCompany()
{
return $this->company;
}
}
我不知道还有什么可以做的,希望你能想出一个主意!感谢您的宝贵时间。
【问题讨论】: