教义2.3实体生成器:样本,文档? [英] Doctrine 2.3 Entity Generator: samples, docs?
问题描述
任何人都可以参考一本书,文章甚至代码示例?
首先你需要 bootstrap Doctrine
并获取一个 EntityManager
的实例,那么你一旦你可以执行以下操作:
$ cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$ cmf-> setEntityManager($ em); // $ em是EntityManager实例
$ metadata = $ cmf-> getAllMetadata();
$ generator = new \Doctrine\ORM\Tools\EntityGenerator();
$ generator-> setGenerateAnnotations(true);
$ generator-> setGenerateStubMethods(true);
$ generator-> setRegenerateEntityIfExists(true);
$ generator-> setUpdateEntityIfExists(false);
$ generator-> generate($ metadata,'/ path / to / entities');
有关配置的更多信息,请阅读:
http://docs.doctrine-project.org/projects/ doctrine-orm / en / latest / reference / configuration.html
Doctrine can generate entities based on small data input, including relation information. However, i have failed to find any example or concise information on the topic. The official documentation only has a small paragraph, with a minor command line example, explaining absolutely nothing,
Can anyone refer to a book, article or even code sample of this?
First you need to bootstrap Doctrine
and get an instance of EntityManager
, then you once you have it, you can do the following:
$cmf = new Doctrine\ORM\Tools\DisconnectedClassMetadataFactory();
$cmf->setEntityManager($em); // $em is EntityManager instance
$metadata = $cmf->getAllMetadata();
$generator = new \Doctrine\ORM\Tools\EntityGenerator();
$generator->setGenerateAnnotations(true);
$generator->setGenerateStubMethods(true);
$generator->setRegenerateEntityIfExists(true);
$generator->setUpdateEntityIfExists(false);
$generator->generate($metadata, '/path/to/entities');
For more information on the configuration, read this:
http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html
这篇关于教义2.3实体生成器:样本,文档?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!