Doctrine控制台程序

时间:2012-02-29 08:32:17

标签: php doctrine-orm

我正在学习学说。我通过Tarball下载配置doctrine 2.2.0。现在在生成数据库模式时遇到麻烦。无法使用命令行工具和以下代码:

<?php
// doctrine.php - Put in your application root

use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper;
use Doctrine\DBAL\Tools\Console\Helper\EntityManagerHelper;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Symfony\Component\Console\Helper\HelperSet;

$lib = "../DoctrineORM-2.2.0";
require $lib . '/Doctrine/ORM/Tools/Setup.php';
Setup::registerAutoloadDirectory($lib);

$paths = array("/path/to/entities-or-mapping-files");
$isDevMode = false;

$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$dbParams = array(
    'dbname' => 'mydb',
    'user' => 'root',
    'password' => '',
    'host' => '127.0.0.1',
    'driver' => 'pdo_mysql'
);
$em = EntityManager::create($dbParams, $config);

$helperSet = new HelperSet(array(
    'db' => new ConnectionHelper($em->getConnection()),
    'em' => new EntityManagerHelper($em)
));

ConsoleRunner::run($helperSet);

这里的错误。

  

致命错误:第30行的E:\ wamp \ www \ project \ doctrine.php中找不到“Doc​​trine \ DBAL \ Tools \ Console \ Helper \ EntityManagerHelper”

我在DoctrineORM-2.2.0 \ Doctrine \ DBAL \ Tools \ Console \ Helper下找不到EntityManagerHelper.php。

1 个答案:

答案 0 :(得分:2)

似乎EntityManagerHelper位于不同的名称空间下:

namespace Doctrine\ORM\Tools\Console\Helper;