El cargador automático de doctrine2 con cli debe usar AnnotationRegistry

Debo usar\Doctrine\Common\Annotations\AnnotationRegistry::registerFile Para acceder al registro de anotaciones en archivos de entidades.

Esta parte es necesaria para utilizar la cadena de controladores y el uso de orm: schema-tool: creator. pero no puedo agregar cada clase que necesité agregandoAnnotationRegistry::registerFile.

este problema se vio cuando quiero agregar Gedmo a mi Doctrine 2.2.2.

<code>// cli-config.php
// if comment this like an error will appear 
// \Doctrine\Common\Annotations\AnnotationRegistry::registerFile(__DIR__ . '/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php');

// cache
$cache = new \Doctrine\Common\Cache\ArrayCache();

// annotation reader
$annotationReader = new \Doctrine\Common\Annotations\AnnotationReader();

// cached annotation reader
$cachedAnnotationReader = new \Doctrine\Common\Annotations\CachedReader($annotationReader, $cache);

// driver chain
$driverChain = new \Doctrine\ORM\Mapping\Driver\DriverChain();

// annotation driver
$annotationDriver = new \Doctrine\ORM\Mapping\Driver\AnnotationDriver($cachedAnnotationReader, array(SCHEMA_PATH));

// add entity namespaces
$driverChain->addDriver($annotationDriver, 'Entity');

// configuration
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl($cache);
$config->setMetadataDriverImpl($driverChain);
$config->setQueryCacheImpl($cache);
$config->setProxyDir(PROXY_PATH);
$config->setProxyNamespace('Proxies');
$config->setAutoGenerateProxyClasses(true);

// entity manager
$entityManager = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);

// helper set
$helperSet = new \Symfony\Component\Console\Helper\HelperSet(array(
            'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($entityManager->getConnection()),
            'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($entityManager)
        ));

// return
return $helperSet;
</code>

y mi archivo de entidad está aquí

<code>namespace Entity;

use \Doctrine\Common\Collections\ArrayCollection;
use \Doctrine\ORM\Mapping as ORM;

/**
 * @ORM\Entity
 * @ORM\Table(name="users")
 */
class User
{
    /**
     * @ORM\Id
     * @ORM\Column(columnDefinition="INT unsigned NOT NULL")
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    protected $id;

    /**
     * @ORM\Column(type="string",length=32)
     */
    protected $name;

    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->_id = $id;
        return $this;
    }

    public function getName()
    {
        return $this->id;
    }

    public function setName($name)
    {
        $this->_id = $name;
        return $this;
    }
}
</code>

el error es:

<code>  [Doctrine\Common\Annotations\AnnotationException]                                                                                       
  [Semantical Error] The annotation "@\Doctrine\ORM\Mapping\Entity" in class Entity\User does not exist, or could not be auto-loaded.
</code>

Respuestas a la pregunta(2)

Su respuesta a la pregunta