首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FOSUserBundle MappingException

FOSUserBundle MappingException
EN

Stack Overflow用户
提问于 2014-11-11 23:21:11
回答 2查看 941关注 0票数 0

我使用Symfony2、FOSUserBundle和Fr3dLdapBundle部署了一个系统,但遇到了以下问题:

代码语言:javascript
复制
MappingException: Class "XXX\Shared\XXXUserBundle\Entity\User" sub class of "FOS\UserBundle\Model\User" is not a valid entity or mapped super class.

这里被解释说eAccelerator是不兼容的,但我没有:

代码语言:javascript
复制
PHP 5.3.3 (cli) (built: Feb 22 2013 02:51:11) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans

在最近的PHP版本中也尝试过,但问题仍然存在:

代码语言:javascript
复制
PHP 5.5.9-1ubuntu4.5 (cli) (built: Oct 29 2014 11:59:10) 
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.5.0, Copyright (c) 1998-2014 Zend Technologies
with Zend OPcache v7.0.3, Copyright (c) 1999-2014, by Zend Technologies

在我的带有Xammp 1.7.7 (PHP5.3.8)的本地主机Windows系统上,一切都很好!

代码语言:javascript
复制
PHP 5.3.8 (cli) (built: Aug 23 2011 11:50:20)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
with Xdebug v2.1.1, Copyright (c) 2002-2011, by Derick Rethans

文件User.php

C:\xampp\htdocs\Symfony2\src\Xyz\Shared\XYUserBundle\Entity\User.php

注意: Xyz和XYUserBundle表示实际的文本大写。

User.php如下:

代码语言:javascript
复制
<?php
namespace Xyz\Shared\XYUserBundle\Entity;

use FOS\UserBundle\Model\User as BaseUser;
use FR3D\LdapBundle\Model\LdapUserInterface;

/**
 * User
 */
class User extends BaseUser implements LdapUserInterface
{

    // Esta variable sirve para almacenar (cache) la ruta del usuario en el LDAP
    protected $dn;

    protected $employeeid;

    /**
     * Set Ldap Distinguished Name
     *
     * @param string $dn Distinguished Name
     */
    public function setDn($dn){
        $this->dn = $dn;

        return $this;
    }

    /**
     * Get Ldap Distinguished Name
     *
     * @return string Distinguished Name
     */
    public function getDn(){
         return $this->dn;
    }


    public function setEmployeeid($employeeid)
    {
        $this->employeeid = $employeeid;

        return $this;        
    }

    public function getEmployeeid(){
        return $this->employeeid;
    }

    public function serialize()
    {
        return serialize(array(
            $this->password,
            $this->salt,
            $this->usernameCanonical,
            $this->username,
            $this->emailCanonical,
            $this->email,
            $this->expired,
            $this->locked,
            $this->credentialsExpired,
            $this->enabled,
            $this->id,
            $this->roles,
            $this->dn,
        ));
    }

    public function unserialize($serialized)
    {
        list(
            $this->password,
            $this->salt,
            $this->usernameCanonical,
            $this->username,
            $this->emailCanonical,
            $this->email,
            $this->expired,
            $this->locked,
            $this->credentialsExpired,
            $this->enabled,
            $this->id,
            $this->roles,
            $this->dn,
        ) = unserialize($serialized);
    }

}

文件User.orm.yml

C:\xampp\htdocs\Symfony2\src\Xyz\Shared\XYUserBundle\Resources\config\Doctrine\User.orm.yml

代码语言:javascript
复制
Xyz\Shared\XYUserBundle\Entity\User:
    type:  entity
    table: fos_user
    id:
        id:
            type: integer
            generator:
                strategy: AUTO
    fields:
        dn:
            type: string
            nullable: false
            length: 255
            fixed: false
            comment: ''
            column: dn
        employeeid:
            type: string
            nullable: false
            length: 15
            fixed: false
            comment: ''
            column: employeeid

,有什么问题吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-02-24 19:39:54

问题是大写的config/Doctrine目录名。

sstokGitHub中求解

票数 0
EN

Stack Overflow用户

发布于 2015-02-23 23:40:21

我觉得你的问题是,你没有用

/** * @ORM\Entity() **/

在用户实体的开头

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26876473

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档