du248227 2019-06-28 11:30
浏览 134
已采纳

MappingException与Doctrine ORM - 类不存在

I am using Doctrine 2.6.2 in my PHP project. The Schema was created successfully with the ORM-Tool, but on runtime, a MappingException is thrown.

I still cannot make sense out of the Exception Error message "Class 'credentials' does not exist in ..." because I don't know about doctrines internals.

my composer.json file:

{
    "require": {
        "doctrine/orm": "^2.6.2",
        "symfony/yaml": "2.*"
    },
    "autoload": {
        "psr-0": {"": "src/"}
    }
}

I tried to change some phpdoc annotations and reset the schema multiple times.

Does someone has experienced similar issues with doctrine? I'd love some hint about this, because I'm not even sure if this problem is caused by my PHP code files or maybe by some misconfiguration of the orm tool I'm using, or most probably by something I didn't think of yet.

/**
 * @Entity @Table(name="credentials")
 */
class Credentials
{

    /** @Id @Column(type="integer") @GeneratedValue **/
    protected $id;

    /** @Column(type="string") **/
    public $Email;

    /** @Column(type="string") **/
    public $Loginname;

    /** @Column(type="string") **/
    public $EntropyString;

    /** @Column(type="string") **/
    public $AccessToken;


    public function __construct()
    {

    }

    public function getId()
    {
        return $this->id;
    }

}

Here is the full Response from apache:

Fatal error: Uncaught Doctrine\Common\Persistence\Mapping\MappingException: Class 'credentials' does not exist in F:\XAMPP\httpd.private\src\php\vendor\doctrine\persistence\lib\Doctrine\Common\Persistence\Mapping\MappingException.php:93 Stack trace: #0 F:\XAMPP\httpd.private\src\php\vendor\doctrine\persistence\lib\Doctrine\Common\Persistence\Mapping\RuntimeReflectionService.php(24): Doctrine\Common\Persistence\Mapping\MappingException::nonExistingClass('credentials')

1 F:\XAMPP\httpd.private\src\php\vendor\doctrine\persistence\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(250):

Doctrine\Common\Persistence\Mapping\RuntimeReflectionService->getParentClasses('credentials')

2 F:\XAMPP\httpd.private\src\php\vendor\doctrine\persistence\lib\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(283):

Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory->getParentClasses('credentials')

3 F:\XAMPP\httpd.private\src\php\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadat

in F:\XAMPP\httpd.private\src\php\vendor\doctrine\persistence\lib\Doctrine\Common\Persistence\Mapping\MappingException.php on line 93

the error occurs on a call to EntityManager's Find method:

$this->credentials = $this->entityManager->Find('credentials', $result[0]["id"]);
  • 写回答

1条回答 默认 最新

  • dongyan1808 2019-06-28 17:31
    关注

    The Exception does not occur anymore after adding the fully qualified class name to the call on EntityManager's Find method:

    $this->credentials = $this->entityManager->Find('Businessrelations\Database\Credentials', $result[0]["id"]);
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 基于双目测规则物体尺寸
  • ¥15 wegame打不开英雄联盟
  • ¥15 公司的电脑,win10系统自带远程协助,访问家里个人电脑,提示出现内部错误,各种常规的设置都已经尝试,感觉公司对此功能进行了限制(我们是集团公司)
  • ¥15 救!ENVI5.6深度学习初始化模型报错怎么办?
  • ¥30 eclipse开启服务后,网页无法打开
  • ¥30 雷达辐射源信号参考模型
  • ¥15 html+css+js如何实现这样子的效果?
  • ¥15 STM32单片机自主设计
  • ¥15 如何在node.js中或者java中给wav格式的音频编码成sil格式呢
  • ¥15 不小心不正规的开发公司导致不给我们y码,