Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/symfony/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 现有类上的条令映射异常_Php_Symfony_Doctrine Orm - Fatal编程技术网

Php 现有类上的条令映射异常

Php 现有类上的条令映射异常,php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,我正在使用Symfony 2.4、Sonata Admin和Fos用户包。尝试访问登录表单屏幕时,我遇到以下错误: MappingException: Class 'Telefonica\SIGREH\CoreBundle\Entity\Usuario' does not exist 但是,在执行php应用程序/控制台原则:mapping:info时,我得到以下输出: Found 14 mapped entities: [OK] FOS\UserBundle\Entity\Group [

我正在使用Symfony 2.4、Sonata Admin和Fos用户包。尝试访问登录表单屏幕时,我遇到以下错误:

MappingException: Class 'Telefonica\SIGREH\CoreBundle\Entity\Usuario' does not exist 
但是,在执行php应用程序/控制台原则:mapping:info时,我得到以下输出:

Found 14 mapped entities:
[OK]   FOS\UserBundle\Entity\Group
[OK]   FOS\UserBundle\Entity\User
[OK]   Sonata\UserBundle\Entity\BaseGroup
[OK]   Sonata\UserBundle\Entity\BaseUser
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Cargo
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Departamento
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Horario
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Motivo
[OK]   Telefonica\SIGREH\CoreBundle\Entity\NivelAcademico
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Oficina
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Region
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Requisicion
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Telefono
[OK]   Telefonica\SIGREH\CoreBundle\Entity\Usuario
我的实体的名称空间是正确的,我已经检查了很多次

在我的config.yml中,我有以下几行:

sonata_admin:
    security:
        handler: sonata.admin.security.handler.noop

sonata_user:
    manager_type: orm

fos_user:
    db_driver: orm
    firewall_name: admin
    user_class: Telefonica\SIGREH\CoreBundle\Entity\Usuario
    service:
        user_manager: sonata.user.orm.user_manager
在我的AppKernel.php中,我添加了

new FOS\UserBundle\FOSUserBundle(),

new Sonata\CoreBundle\SonataCoreBundle(),
new Sonata\UserBundle\SonataUserBundle(),
new Sonata\BlockBundle\SonataBlockBundle(),
new Sonata\jQueryBundle\SonatajQueryBundle(),
new Knp\Bundle\MenuBundle\KnpMenuBundle(),

new Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle(),

// Then add SonataAdminBundle
new Sonata\AdminBundle\SonataAdminBundle(),

new Telefonica\SIGREH\CoreBundle\TelefonicaSIGREHCoreBundle(),
Usuario实体如下所示:

<?php

namespace Telefonica\SIGREH\CoreBundle\Entity;

use Doctrine\ORM\Mapping as ORM;
use FOS\UserBundle\Entity\User as BaseUser;
use Symfony\Component\Validator\Constraints as Assert;

/**
 * @ORM\Entity
 * @ORM\Table(name="usuario")
 */
class Usuario extends BaseUser
{
    /**
    * @ORM\Id
    * @ORM\Column(type="integer")
    * @ORM\GeneratedValue(strategy="AUTO")
    */
    protected $id;

    /**
     * @var string
     * 
     * @ORM\Column(name="nombre", type="string", length=50, nullable=true)
     * 
     * @Assert\Length(max=50)
     * @Assert\NotBlank
     */
     protected $nombre;

    /**
     * @var string
     * 
     * @ORM\Column(name="apellido", type="string", length=50, nullable=true)
     * @Assert\Length(max=50)
     * 
     */
     protected $apellido;

    public function __construct() {
        parent::__construct();
    }
 }

问题是我做错了什么?

这可能是symfony造成的。在您的问题上添加symfony标记。我们可以查看Usuario实体的声明吗?请尝试使用\Telefonica\SIGREH\CoreBundle\entity\Usuario。在我的例子中,名称空间根的反斜杠修复了这个问题,我已经尝试过了,但没有成功