Doctrine 2 - Does not recognize class mapped with $ entityManager-getRepository ()

1

I'm going to be a little ...

In my bootstrap.php file I'm trying to get the repository of a given entity and gives Fatal Error , stating that the Class does not exist, but it exists. Here is the error message:

Fatal error: Uncaught exception 'Doctrine\Common\Persistence\Mapping\MappingException' with message 'Class 'Grupos' does not exist' in C:\wamp\www\projetoTeste\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\MappingException.php on line 96
Doctrine\Common\Persistence\Mapping\MappingException: Class 'Grupos' does not exist in C:\wamp\www\projetoTeste\vendor\doctrine\common\lib\Doctrine\Common\Persistence\Mapping\MappingException.php on line 96


Here my bootstrap:

// o Doctrine utiliza namespaces em sua estrutura, por isto estes uses
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;

// Criar uma configuração simples ["default"] de Doctrine ORM para Annotations
$isDevMode = true;
$pathEntitys = array(__DIR__."/src/Projeto/Core/Model", __DIR__."/src/Projeto/App/Model");

$config = Setup::createAnnotationMetadataConfiguration($pathEntitys, $isDevMode);

// Parâmetros de Configuração do Banco de Dasdos
require_once(DBCONFIG.'dbconfig.php');

// Obtendo o Entity Manager com base nas configurações anteriores
$entityManager = EntityManager::create($dbParams, $config);

// Testando $entityManager->getRepository() ** Nesta linha que dá erro **
$gruposRepository = $entityManager->getRepository('Grupos');


And here the Entity, located in /src/Project/Core/Model/Groups.php

namespace Projeto\Core\Model;

/**
 * @Entity
 * @Table(name="grupos")
 */
class Grupos extends \Projeto\Core\Model\Model
{
    /**
     * @Id
     * @GeneratedValue(strategy="AUTO")
     * @Column(type="integer", name="grup_id")
     */
    private $id;

    /**
     * @Column(type="string", name="grup_nome")
     */
    private $nome;

    /**
     * @Column(type="integer", name="grup_status")
     */
    private $status;

    /**
     * @Column(type="datetime", name="grup_dtInsert")
     */
    private $dtInsert;

    /**
     * @Column(type="datetime", name="grup_dtIEdit")
     */
    private $dtEdit;

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

    public function getNome()
    {
        return $this->nome;
    }

    public function getStatus()
    {
        return $this->status;
    }

    public function getDtInsert()
    {
        return $this->dtInsert->format('Y-m-d H:i:s');
    }

    public function getDtEdit()
    {
        return $this->dtEdit->format('Y-m-d H:i:s');
    }

    public function setNome($nome)
    {
        $this->nome = $nome;
    }

    public function setStatus($status)
    {
        $this->status = $status;
    }

    public function setDtInsert()
    {
        $this->dtInsert = new \DateTime();
    }

    public function setDtEdit()
    {
        $this->dtEdit = new \DateTime();
    }
}
    
asked by anonymous 02.07.2014 / 14:39

1 answer

2

You have to put the full name of the class, with the namespace:

$gruposRepository = $entityManager->getRepository('Projeto\Core\Model\Grupos');
    
02.07.2014 / 15:58