【发布时间】:2015-04-10 20:24:58
【问题描述】:
我对 Doctrine 提出了一个非常奇怪的问题。它无法加载特定实体的元数据。我所有其他实体都加载正常,但是当我尝试加载以下 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://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Foo\ContentBundle\Entity\Item" table="content_item">
<id name="id" column="id" type="integer">
<generator strategy="AUTO" />
</id>
<field name="gid" column="gid" type="string" nullable="false" unique="false" />
<field name="url" column="url" type="string" nullable="true" unique="false" />
<field name="title" column="title" type="string" nullable="false" unique="false" />
<field name="content" column="content" type="text" nullable="false" unique="false" />
<field name="timestamp" column="timestamp" type="datetime" nullable="false" unique="false" />
<many-to-one field="feed" target-entity="Foo\ContentBundle\Entity\Feed">
<join-column name="feed" referenced-column-name="id" nullable="false" on-delete="CASCADE" />
</many-to-one>
</entity>
它会抛出以下异常:
Invalid mapping file 'Foo.ContentBundle.Entity.Item.orm.xml' for class 'Foo\ContentBundle\Entity\Item'.
而 libxml2 给了我以下错误:
failed to load external entity "/Users/ramon/Development/foo/src/Foo/ContentBundle/Resources/config/doctrine/Item.orm.xml"
奇怪的是,我所有的其他实体都很好!有没有人知道如何解决这个问题?
我正在使用 libxml 2.9.0 版、Doctrine ORM 2.4.7 版和 Symfony 2.6 版以及 PHP 5.6.5。
[edit] 忘记了最好的部分:这只发生在我加载元数据以从存储库中获取实体时。不是在我将实体插入存储库时。
另外,当我尝试使用 simplexml_load_file 手动加载文件时,它工作正常。
【问题讨论】:
标签: php symfony doctrine-orm doctrine libxml2