facing this type of issue. I am new in doctrine with codeigniter.
Fatal error: Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class "Entity\Options" is not a valid entity or mapped super class.' in D:\xampp\htdocs\doctrineGit\application\libraries\Doctrine\ORM\Mapping\MappingException.php:336 Stack trace: #0 D:\xampp\htdocs\doctrineGit\application\libraries\Doctrine\ORM\Mapping\Driver\AnnotationDriver.php(89): Doctrine\ORM\Mapping\MappingException::classIsNotAValidEntityOrMappedSuperClass('Entity\Options') #1 D:\xampp\htdocs\doctrineGit\application\libraries\Doctrine\ORM\Mapping\ClassMetadataFactory.php(117): Doctrine\ORM\Mapping\Driver\AnnotationDriver->loadMetadataForClass('Entity\Options', Object(Doctrine\ORM\Mapping\ClassMetadata)) #2 D:\xampp\htdocs\doctrineGit\application\libraries\Doctrine\Common\Persistence\Mapping\AbstractClassMetadataFactory.php(318): Doctrine\ORM\Mapping\ClassMetadataFactory->doLoadMetadata(Object(Doctrine\ORM\Mapping\ClassMetadata), NULL, false, Array) #3 D:\xampp\htdocs\doctrineGit\application\libraries\Doctrine\Common\Persistenc in D:\xampp\htdocs\doctrineGit\application\libraries\Doctrine\ORM\Mapping\MappingException.php on line 336
Here is my entityclass
<?php
use Doctrine\ORM\Mapping as ORM;
/**
* Options
*
* @ORM\Table(name="options")
* @ORM\Entity
*/
class Options
{
/**
* @var integer
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=50, nullable=true)
*/
private $name;
/**
* @var boolean
*
* @ORM\Column(name="active", type="boolean", nullable=true)
*/
private $active = '1';
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set name
*
* @param string $name
* @return Options
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
Below is my model class or repository using like this where i am going wrong
<?php
use models\Entity\Options;
class OptionsRepository extends CI_Model {
public $em;
public function __construct() {
parent::__construct();
$this->load->library('doctrine');
$this->em = $this->doctrine->em;
}
public function getOptions() {
$dql = "SELECT o FROM \Entity\Options o";
$query = $this->em->createQuery($dql);
return $query->getResult();
}
}
?>