小编Joh*_*gan的帖子

尝试运行doctrine命令时"em未定义错误"

我刚刚设置了一个ZF2项目并为Doctrine2配置了所有项目而没有问题.它工作,现在只是给我一个错误,因为它找不到我想要查询的数据库表.

实体也正确设置,全部按照http://www.jasongrimes.org/2012/01/using-doctrine-2-in-zend-framework-2/

所以想使用CLI来创建表等,但是在运行任何CLI命令时我都会得到

[InvalidArgumentException]       
The helper "em" is not defined.
Run Code Online (Sandbox Code Playgroud)

我正在使用的命令

php doctrine.php orm:schema-tool:update --dump-sql
Run Code Online (Sandbox Code Playgroud)

我从文件夹运行doctrine.php

/Library/WebServer/Documents/zf2-Skel-NewProj1/vendor/bin
Run Code Online (Sandbox Code Playgroud)

现在,如果我将CLI用于我的一个ZF1.11项目,它可以正常工作.

为了实现这一点,我必须编辑位于其下的cli-config.php文件

/Library/WebServer/Documents/zf2-Skel-NewProj1/vendor/doctrine/orm/tools
Run Code Online (Sandbox Code Playgroud)

该文件的内容是:

<?php

require_once '../../lib/vendor/doctrine-common/lib/Doctrine/Common/ClassLoader.php';

$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\ORM', realpath(__DIR__ . '/../../lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\DBAL', realpath(__DIR__ . '/../../lib/vendor/doctrine-dbal/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Doctrine\Common', realpath(__DIR__ . '/../../lib/vendor/doctrine-common/lib'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Symfony', realpath(__DIR__ . '/../../lib/vendor'));
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__);
$classLoader->register();

$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$driverImpl = $config->newDefaultAnnotationDriver(array(__DIR__."/Entities"));
$config->setMetadataDriverImpl($driverImpl);

$config->setProxyDir(__DIR__ …
Run Code Online (Sandbox Code Playgroud)

configuration zend-framework command-line-interface doctrine-orm

0
推荐指数
1
解决办法
3142
查看次数