如何在zenframework上配置doctrine命令行工具2 [英] how to configure doctrine command line tools on zenframework 2
问题描述
我希望使用 doctrine的命令行工具以生成实体等。
我遵循了doctrine的说明,并在我的应用程序的根目录中创建了一个cli-config.php页面:
< a href =http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html =nofollow> http://docs.doctrine-project.org/ projects / doctrine-orm / en / latest / reference / configuration.html
我失去了两个问题;
配置需要 bootstrap php page ;然而,zendframework 2不使用引导页;那么什么会是等价的?
其次,它要求我们获得一个实体管理者;下面的方法是获取实体管理器的正确方法:
public function getEntityManager()
{
if(null === $ this-> em){
$ this-> em = $ this-> getServiceLocator() - > get('doctrine.entitymanager.orm_default');
}
return $ this-> em;下面是cli-config.php页面的外观:
}
<
// cli-config.php
require_once'my_bootstrap.php';
//从应用程序访问EntityManager的任何方法
$ em = GetMyEntityManager();
$ 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)
));
我会非常感谢任何帮助或建议。
温暖的问候
Andreea
它无效,因为我使用的是 cygdrive命令行。然而,当我切换到git bash它工作完美。与git bash我必须使用命令:
C:> cd project-directory
project-dir> vendor \bin\doctrine-module orm:validate-schema
如果您已使用启动项目Zend Skeleton Application 你有一个composer.json文件。您只需要包含DoctrineORMModule (此处的说明)
然后,使用CMD键入
C:> cd project-directory
project-dir> vendor\bin\doctrine-module orm:validate-schema
你去了。
i am using doctrine 2 on zendframework 2. i have configured both correcly and they are both working.
i however wish to use doctrine's command line tool to generate entities etc.
i have followed doctrine's instructions and created a cli-config.php page in the root of my application: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html
i am however lost on two issues; the configuration requires a bootstrap php page; however, zendframework 2 does not use a bootstrap page; so what would the equivalent be?
Secondly, it requires us to obtain an entity mangager; would the method below be the correct way to get the entity manager:
public function getEntityManager()
{
if (null === $this->em) {
$this->em = $this->getServiceLocator()->get('doctrine.entitymanager.orm_default');
}
return $this->em;
}
below is how the cli-config.php page should look;
// cli-config.php
require_once 'my_bootstrap.php';
// Any way to access the EntityManager from your application
$em = GetMyEntityManager();
$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)
));
i would really appreciate any help or advice on this matter.
warm regards
Andreea
the matter has been resolved:!!
it did not work because i was using a cygdrive command line. however, when i switched to git bash it worked perfectly. with git bash i have to use the command:
C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema
If you have started your project using the Zend Skeleton Application you do have a composer.json file. You just need to include the DoctrineORMModule (instructions here)
Then, using the CMD just type
C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema
There you go.
这篇关于如何在zenframework上配置doctrine命令行工具2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!