Doctrine 2 - No Metadata Classes to process by orm:generate-repositories
Doctrine 2 - No Metadata Classes to process by orm:generate-repositories
我正在尝试生成实体仓库,但出现以下消息:
No Metadata Classes to process
我发现使用了以下代码:
use Doctrine\ORM\Mapping as ORM;
和
@ORM\Table
但它们的工作并不正常。
如果我将所有的@ORM\Table更改为只有@Table(和其他注释)- 它就开始工作了,但我真的不想以这种方式进行,因为它应该能够使用@ORM注释来工作。
我按照以下页面的说明进行操作,但没有成功。我知道我离成功很近,但可能是文件路径或命名空间方面的问题。请帮忙。
http://docs.doctrine-project.org/projects/doctrine-common/en/latest/reference/annotations.html
有人遇到过这样的问题吗?我漏掉了什么?
cli-config,
use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\Common\Annotations\AnnotationRegistry; require_once 'Doctrine/Common/ClassLoader.php'; define('APPLICATION_ENV', "development"); error_reporting(E_ALL); //AnnotationRegistry::registerFile("Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"); //AnnotationRegistry::registerAutoloadNamespace("Symfony\Component\Validator\Constraint", "Doctrine/Symfony"); //AnnotationRegistry::registerAutoloadNamespace("Annotations", "/Users/ivv/workspaceShipipal/shipipal/codebase/application/persistent/"); $classLoader = new \Doctrine\Common\ClassLoader('Doctrine'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__ . '/application/'); $classLoader->register(); $classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__ . '/application/persistent'); $classLoader->register(); $config = new \Doctrine\ORM\Configuration(); $config->setProxyDir(__DIR__ . '/application/persistent/Proxies'); $config->setProxyNamespace('Proxies'); $config->setAutoGenerateProxyClasses((APPLICATION_ENV == "development")); $driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__ . "/application/persistent/Entities")); $config->setMetadataDriverImpl($driverImpl); if (APPLICATION_ENV == "development") { $cache = new \Doctrine\Common\Cache\ArrayCache(); } else { $cache = new \Doctrine\Common\Cache\ApcCache(); } $config->setMetadataCacheImpl($cache); $config->setQueryCacheImpl($cache); $connectionOptions = array( 'driver' => 'pdo_mysql', 'host' => '127.0.0.1', 'dbname' => 'mydb', 'user' => 'root', 'password' => '' ); $em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config); $platform = $em->getConnection()->getDatabasePlatform(); $platform->registerDoctrineTypeMapping('enum', 'string'); $helperSet = new \Symfony\Component\Console\Helper\HelperSet(array( 'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()), 'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em) ));
User.php(工作版本,最初的版本如说明所述,@Table是@ORM\Table,其他注释类似也有@ORM\部分,如@ORM\Column等)