murze
murze

Reputation: 4103

How to install the gedmo-extensions in Doctrine2?

i'm trying to install the "gedmo" behaviourial extensions (version 2.1.0-DEV) in Doctrine2 (version 2.1.3).

Without the extensions everything works fine. However, when I add the annotationdriver to read the @gedmo-annotations errors such as "Uncaught exception 'Doctrine\ORM\Mapping\MappingException' with message 'Class User2 is not a valid entity or mapped super class" are thrown. This is de User2-entity:

<?php

use \Doctrine\ORM\Mapping as ORM;

/** @ORM\Entity  */
class User2 {

    /**
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue
     */
    private $id;

    /** @ORM\Column(length=255) */
    private $username;
}

Because these errors occur even in the Entities where @gemdo is not used i suspect it has something to do with the way the annotationdrivers are configured. In my bootstrap-file the annotation driver is added (i'm only going to use the tree-extension):

$reader = new \Doctrine\Common\Annotations\AnnotationReader();
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($reader);

$chain = new \Doctrine\ORM\Mapping\Driver\DriverChain;
$chain->addDriver($annotationDriver, 'Gedmo\Tree\Entity');

$config->setMetadataDriverImpl($chain);

A few questions:

  1. Should I add a driver for the ORM-annotation?
  2. Is there something wrong with the User2-class?
  3. How can I get a more specific user-error enabling me to find the exact cause of the problem?

In short: how can I make the @orm and @gedmo annotations work?

Upvotes: 2

Views: 4742

Answers (1)

Gediminas
Gediminas

Reputation: 878

there was recently an example added in order to show how to configure bare entity manager with extensions whithout any framework used. You can follow the readme at the bottom on how to setup it initially

Upvotes: 2

Related Questions