找不到“EventManager”类

时间:2013-03-11 16:57:27

标签: doctrine-orm

我正在尝试了解Doctrine中的事件,但是当我阅读the docs时,我被困在第一行:

$evm = new EventManager();

我来了

  

PHP致命错误:未找到类'EventManager'

我该如何解决这个问题?

以下是完整的代码:

use Doctrine\ORM\Tools\Setup;

require_once("Doctrine/ORM/Tools/Setup.php");
Setup::registerAutoloadPEAR();

$classLoader = new Doctrine\Common\ClassLoader('Entities', __DIR__);
$classLoader->register();

$paths = array();
$isDevMode = true;
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$dbParams = array("driver" => "pdo_mysql",
    "host" => variable_get("dbManip_host"),
    "user" => variable_get("dbManip_user"),
    "password" => variable_get("dbManip_password"),
    "dbname" => variable_get("dbManip_dbName"),
    "charset" => "utf8");
global $entityManager_globalObject;
$entityManager_globalObject = \Doctrine\ORM\EntityManager::create($dbParams, $config);
$entityManager_globalObject->getConnection()->exec("SET NAMES UTF8");

$evm = new EventManager();

1 个答案:

答案 0 :(得分:1)

您正在寻找班级Doctrine\Common\EventManager

$evm = new \Doctrine\Common\EventManager();

use Doctrine\Common\EventManager; // at the top of your file

$evm = new EventManager();