即时通讯与初学者的教条。我刚安装了pear + doctrine 2.3.3并想测试它。PHP学说初学者:学说 ORM 工具安装程序找不到
测试教义我写了一个名为 “Person”
/**
* @Entity
*/
class person
{
/** @Id @Column(type="integer") @GeneratedValue * */
private $id;
/** @Column(type="string") * */
private $name;
/** @Column(type="string") * */
private $surname;
//some getters and setters ...
}
类之后,我做了我的bootstrap.php文件,bootstrep_doctrine.php和CLI-config.php文件的文件并运行命令:
doctrine orm:schema-tool:create
工作正常!
但是现在,当我想在一个“正常”的php文件我bootstrap.php中,创建一个“人”,我收到以下错误:
Fatal error: Class 'Doctrine\ORM\Tools\Setup' not found
in /var/www/vms/bootstrap_doctrine.php on line 15
文件看起来像如下:
<?php
$debug = true;
if($debug){
error_reporting(E_ALL);
ini_set("display_errors", "on");
ini_set("display_startip_errors", "on");
}
require_once '../bootstrap.php';
include_once ('testClassOrm.php');
$person = new person();
$person = new person();
$person->setName("Hans");
?>
bootstrap.php中:
if(!class_exists("Doctrine\Common\Version", false)){
require_once 'bootstrap_doctrine.php';
}
bootstrap_doctrine.php
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
$paths = array("entities/");
$isDevMode = true;
// the connection configuration
$dbParams = array(
'driver' => 'pdo_mysql',
'user' => 'TEST',
'password' => 'TEST',
'dbname' => 'test',
);
$config = Setup::createAnnotationMetadataConfiguration($paths, $isDevMode);
$em = EntityManager::create($dbParams, $config);
我检查/ usr/share/pear /是否在php_include路径中。它是..
require_once 'System.php';
var_dump(class_exists('System', false));
返回true:
但是这一次确实返回false:
use Doctrine\ORM\Tools\Setup;
var_dump(class_exists('Setup', false));
我做错什么了吗?
问候
你忘了设定自动加载!你是如何安装ORM的? – Ocramius