command-line - 如何在 zenframework 2 上配置 doctrine 命令行工具

标签 command-line doctrine-orm zend-framework2

我在 zendframework 2 上使用 doctrine 2。我已经正确配置了它们并且它们都在工作。

但是我希望使用doctrine 的命令行工具 来生成实体等。

我已经按照 doctrine 的说明在我的应用程序的根目录中创建了一个 cli-config.php 页面: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/reference/configuration.html

然而,我在两个问题上迷失了方向; 配置需要一个bootstrap php 页面;然而,zendframework 2 不使用引导页面;那么等价物是什么?

其次,它需要我们获得一个entity manager;以下方法是否是获取实体管理器的正确方法:

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';

// 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)
));

我非常感谢任何有关此事的帮助或建议。

亲切的问候

安德烈亚

事情已经解决了:!!

它不起作用,因为我使用的是 cygdrive command line .然而,当我切换到 git bash 时,它工作得很好。使用 git bash 我必须使用命令:

C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema

最佳答案

如果您使用 Zend Skeleton Application 开始了您的项目你有一个 composer.json 文件。你只需要包含 DoctrineORMModule (instructions here)

然后,使用 CMD 只需键入

C: > cd project-directory
project-dir > vendor\bin\doctrine-module orm:validate-schema

给你。

关于command-line - 如何在 zenframework 2 上配置 doctrine 命令行工具,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21523766/

相关文章:

ios - 如何创建目标、向该目标添加资源并使用 xcode 命令行工具构建目标?

java处理命令行输入

php - Doctrine批量删除join表记录

php - ZF2 mysql带区间查询

validation - 如何在 Zend 框架 2 中使用没有表单类的 InputFilter

mysql - 从 Zend Framework 2 中生成的 MYSQL 中删除引号

git - 下载与主题匹配的 GitHub 存储库列表?

在提示中获取未 merge 路径的 Git 快捷方式

symfony - 在 Doctrine 2 中获取自定义字段

php - 数据库中的表与实体模式不一致