class_parents():类不存在

时间:2012-11-08 18:27:50

标签: php doctrine doctrine-orm

我设置了以下层次结构:

/src
    /application
        /models
            User.php, Item.php, etc.
   /config
        /mappings
            /yaml
                application.models.User.dcm.yml

模型是命名空间“application \ models”。他们都“使用Doctrine \ ORM \ Mapping AS ORM”;我在我的bootstrap中使用了Doctrine的ClassLoader。这些似乎都有效。

每当我运行应用程序时,都会出现以下错误:

Warning: class_parents(): Class User does not exist and could not be loaded in /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php on line 40

Warning: array_reverse() expects parameter 1 to be array, boolean given in /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 257

Warning: Invalid argument supplied for foreach() in /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php on line 257

Fatal error: Uncaught exception 'ReflectionException' with message 'Class User does not exist' in /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php:73
Stack trace:
#0 /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php(73): ReflectionClass->__construct('User')
#1 /Library/WebServer/Documents/goodsam/library/Doctrine/ORM/Mapping/ClassMetadataInfo.php(867): Doctrine\Common\Persistence\Mapping\RuntimeReflectionService->getClass('User')
#2 /Library/WebServer/Documents/goodsam/library/Doctrine/ORM/Mapping/ClassMetadataFactory.php(511): Doctrine\ORM\Mapping\ClassMetadataInfo->initializeReflection(Object(Doctrine\Common\Persistence\Mapping\RuntimeReflectionService))
#3 /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/AbstractClassMetadataFactory.php(300): Doctrine\ORM\Mapping\ClassMetadataFactory->initializeReflection(Object(Doctrine\ORM\Mapping\ClassMetadata), Object(Doctrine\Comm in /Library/WebServer/Documents/goodsam/library/Doctrine/Common/Persistence/Mapping/RuntimeReflectionService.php on line 73

首先,Doctrine说yaml映射文件必须是完全限定的类名。因此,我将其命名为指向application \ models目录的位置。但是在示例文档中,看起来它想要对映射文件本身进行完全限定?这应该是哪一个?

这是我的映射文件的顶部:

# application.models.User.dcm.yml
application\models\User: 

如果这看起来正确,可能会破坏什么其他线索?

0 个答案:

没有答案