相关疑难解决方法(0)

带cli的doctrine2自动加载器必须使用AnnotationRegistry

我必须使用\Doctrine\Common\Annotations\AnnotationRegistry::registerFile访问实体文件中的注释注册表.

这部分是使用驱动程序链和使用orm:schema-tool:creator所必需的.但我无法通过添加添加我需要的每个类AnnotationRegistry::registerFile.

当我想将Gedmo添加到我的Doctrine 2.2.2时,就会看到这个问题.

// 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 …
Run Code Online (Sandbox Code Playgroud)

annotations command-line-interface autoloader doctrine-orm

6
推荐指数
1
解决办法
6765
查看次数