2
Personal iae...
In my file bootstrap.php I am trying to take the repository of a certain entity and gives Fatal Error
, informing that the Class does not exist, but it does exist. 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();
}
}
That’s right, I forgot the namespaces.... (T_T). Thank you!
– LeoFelipe