Trouble with importing annotations
I resolved this issue by adding the following to my entity file:
use Doctrine\ORM\Mapping as ORM;
So my file now looks like:
<?php
namespace Acme\CustomBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Example
*
* @ORM\Entity
* @ORM\Table(name="example")
*
*/
class Example
{
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var integer
*/
private $id;
/**
* @ORM\Column(type="string", length=125)
*
* @var string
*/
private $title;
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
/**
* Set title
*
* @param string $title
*
* @return Example
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function gettitle()
{
return $this->title;
}
}
I had a similar issue when using Silex, Doctrine2 and the Symfony-Validator.
The solution was to avoid using the SimpleAnnotationsReader and instead using the normal AnnotationReader (have a look at Doctrine\ORM\Configuration::newDefaultAnnotationDriver). You can then preface every entity with ORM\
(and of course inserting use Doctrine\ORM\Mapping as ORM;
in every entity).