Got a zf2 skeleton app, with DoctrineORM with some entities, and all works fine.
Now when i try to add a "Category" entity:
namespace Me\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity
* @ORM\Table(name="me_category")
*/
class Category
{
/**
* @var int
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @var string
* @ORM\Column(type="string", length=255, unique=true)
*/
protected $name;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = (int)$id;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = (string) $name;
}
}
but that gives me the following error:
Fatal error: require_once(): Cannot redeclare class me\entity\category in App/vendor/doctrine/common/lib/Doctrine/Common/Persistence/Mapping/Driver/AnnotationDriver.php on line 197
I figured this was because the Category.php gets required twice. So i got a temporary fix by adding a "guard" in the Category.php
if (defined('CATEGORY_GUARD')) return;
define('CATEGORY_GUARD', true);
This works but of course is not how it's supposed to be done. Anybody who has any idea why this entity gets required twice?
- i have not used the Category entity anywhere
- the first time it is required as: category.php (normal c) the second time as Category.php (capital C)