学说 2 - 没有元数据类需要由 orm:generate-repositories 处理
我正在尝试生成实体存储库并收到此类消息
没有要处理的元数据类
我已经找到了
使用 Doctrine\ORM\Mapping 作为 ORM;并且@ORM\表无法正常工作。
如果我将所有@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\列等)
<?php
namespace Entities;
use Doctrine\Mapping as ORM;
/**
* User
*
* @Table(name="user")
* @Entity(repositoryClass="Repository\User")
*/
class User
{
/**
* @var integer $id
*
* @Column(name="id", type="integer", nullable=false)
* @Id
* @GeneratedValue
*/
private $id;
/**
* @var string $userName
*
* @Column(name="userName", type="string", length=45, nullable=false)
*/
private $userName;
/**
* @var string $email
*
* @Column(name="email", type="string", length=45, nullable=false)
*/
private $email;
/**
* @var text $bio
*
* @Column(name="bio", type="text", nullable=true)
*/
private $bio;
public function __construct()
{
}
}