In a Zend Framework 2 Project, Doctrine 2 is not able to find my Entities and I am not sure why. To me everything looks correct, but the php ./vendor/bin/doctrine-module orm:schema-tool:create
command to create the database based on the entities results in No Metadata Classes to process.
.
Of course I made sure first that all modules are loaded, so it's not that easy ;-) I also already did some research on that problem and it seems that most of the time, it's namespace related, but again, I don't see anything wrong there. I also generated the autoload files.
Are you able to spot anything wrong in these files, why is Doctrine not able to find the Entities? Could it be related to something else than an error in my files?
In module.config.php
, Doctrine is configured like this:
'doctrine' => [
'driver' => [
'Catalog_entities' => [
'class' =>'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => [__DIR__ . '/../src/Catalog/Entity']
],
],
'orm_default' => [
'drivers' => [
'Catalog\Entity' => 'Catalog_entities'
],
],
],
module.config.php
has no namespace
declaration since it's included into Module.php
which has namespace Catalog;
at the top.
The Entity at module/Catalog/src/Catalog/Entity/WorkEntity.php
looks like this:
namespace Catalog\Entity;
use Doctrine\ORM\Mapping as ORM;
/** @ORM\Entity */
class Work {
/**
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @ORM\Column(type="integer")
*/
protected $id;
public function getId() {
return $this->id;
}
public function setId($id) {
$this->id = $id;
}
}