2013-03-11 21 views
0

我想了解有關學說活動,但是當我讀到the docs,我感到迷惑的第一行:類「eventmanager進行」未找到

$evm = new EventManager(); 

在這裏,我得到一個

PHP Fatal error: Class 'EventManager' not found

我該如何解決這個問題?

下面是完整的代碼:

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

您正在尋找Doctrine\Common\EventManager類。

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

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

$evm = new EventManager(); 
+0

這是令人驚訝的簡單(錯誤已消失)。爲什麼他們沒有將這些工作代碼放在文檔中,而不是現在有什麼(非工作代碼)? – Shawn 2013-03-11 17:10:01

+0

@Shawn可能是受到監督的東西。所有的類型提示都會導致這個類,所以不應該很難發現它應該是什麼樣子。另外,您可以在http://www.doctrine-project.org/jira/上的問題跟蹤器上報告問題,或者通過https://github.com/doctrine/doctrine2/tree/打開對文檔的請求。主/文檔 – Ocramius 2013-03-11 17:23:31