我是 Doctrine 2 的新手,所以我使用docs.doctrine-project.org上的文档作为模板来帮助我入门。我已经生成了我需要的所有文件(我认为),现在我正在尝试运行命令
doctrine orm:schema-tool:create
但教义正在吐口水
[Doctrine\ORM\Mapping\MappingException]
Invalid mapping file 'QueryRequest.dcm.xml' for class 'QueryRequest'.
这是我的QueryRequest.dcm.xml(我特别依赖这些文档中的一个教义示例来生成文件):
<?xml version="1.0" encoding="UTF-8"?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping
http://raw.github.com/doctrine/doctrine2/master/doctrine-mapping.xsd">
<entity name="RequestMetadata" table="request_metadata">
<id name="id" type="bigint">
<generator strategy="AUTO" />
</id>
<field name="snapshot" column="snapshot" type="smallint" nullable="true" />
<field name="custID" column="cust_id" type="string" length="8" />
<field name="ipAddress" column="ip_addr" type="string" length="15" />
<field name="query" column="query" type="string" length="500" />
<field name="createdOn" column="created_on" type="datetime" />
<one-to-many field="httpRequestResponses" target-entity="HttpRequestResponse" mapped-by="queryRequest">
<cascade>
<cascade-persist />
</cascade>
<order-by>
<order-by-field name="createdOn" direction="DESC" />
</order-by>
</one-to-many>
<one-to-many field="queryResults" target-entity="QueryResults" mapped-by="queryRequest">
<cascade>
<cascade-persist />
</cascade>
</one-to-many>
</entity>
</doctrine-mapping>
这是QueryRequest.php:
class QueryRequest {
protected $id;
protected $snapshot;
protected $custID;
protected $ipAddress;
protected $query;
protected $createdOn;
protected $httpRequestResponses = null;
protected $queryResults = null;
public function __construct() {
$this->setCreatedOn(new DateTime("now"));
$this->httpRequestResponses = new ArrayCollection();
$this->queryResults = new ArrayCollection();
}
public function getID() {
return $this->id;
}
public function getSnapshot() {
return $this->snapshot;
}
public function setSnapshot($snapshot) {
$this->snapshot = $snapshot;
}
public function getCustID() {
return $this->custID;
}
public function setCustID($id) {
$this->custID = $id;
}
public function getIpAddress() {
return $this->ipAddress;
}
public function setIpAddress($ip) {
$this->ipAddress = $ip;
}
public function getQuery() {
return $this->query;
}
public function setQuery($query) {
$this->query = $query;
}
public function getCreatedOn() {
return $this->createdOn;
}
public function setCreatedOn($createdOn) {
$this->createdOn = $createdOn;
}
}
由于我是新手,我很难发现问题 - 事实上,我什至不确定问题是否与 xml 文件有关。谁能帮我发现问题?