1

我设置了以下层次结构:

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

这些模型的命名空间为“application\models”。他们都“使用 Doctrine\ORM\Mapping AS ORM”;我在引导程序中使用 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: 

如果这看起来是对的,还有其他关于可能被破坏的线索吗?

4

0 回答 0