I am mapping the database with doctrine and am having a problem. When I use Annotations the following way works perfectly:
/**
* @Entity
* @Table(name="customer",uniqueConstraints={@UniqueConstraint(name="email", columns={"email"})})
*/
class Customer {
(atributos)...
}
Well, I want to use use Doctrine\ORM\Mapping AS ORM;
so that annotations
starts with ORM\
Example:
use Doctrine\ORM\Mapping AS ORM;
/**
* @ORM\Entity
* @ORM\Table(name="customer",uniqueConstraints={@ORM\UniqueConstraint(name="email", columns={"email"})})
*/
class Customer {
(atributos)...
}
But in this way the doctrine is not interpreting the class as a valid entity ...
Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class "Customer" is not a valid entity or mapped super class.'
My bootstrap.php looks like this
require_once "vendor/autoload.php";
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$entidades = array("entity/");
$isDevMode = true;
// configurações de conexão.
$dbParams = array(
'driver' => 'pdo_mysql',
'host' => 'localhost',
'user' => 'root',
'password' => 'pass',
'dbname' => 'LojaVirtual',
'charset' => 'UTF8'
);
//setando as configurações definidas anteriormente
$config = Setup::createAnnotationMetadataConfiguration($entidades, $isDevMode);
//criando o Entity Manager com base nas configurações de dev e banco de dados
$entityManager = EntityManager::create($dbParams, $config);
Does anyone know how to solve this problem?