【发布时间】:2013-07-06 15:13:58
【问题描述】:
我最近一直在测试这个Doctrine2 style Neo4j wrapper。虽然以前从未使用过 Doctrine,但我已经从 Github 页面以及 Doctrine 文档中删除了一些很好的示例,并且似乎无法通过某个点。我提取了 Neo4j-PHP-OGM 库,使用 Composer 下载了 Doctrine2,并将 EntityManager 程序化(用于测试)包含在 bootstrap.php 中。
/bootstrap.php
require __DIR__ . '/vendor/autoload.php';
require __DIR__ . '/lib/HireVoice/Neo4j/Annotation/Entity.php';
require __DIR__ . '/lib/HireVoice/Neo4j/Annotation/Auto.php';
require __DIR__ . '/lib/HireVoice/Neo4j/Annotation/Property.php';
require __DIR__ . '/lib/HireVoice/Neo4j/Annotation/Index.php';
require __DIR__ . '/lib/HireVoice/Neo4j/Annotation/ManyToOne.php';
require __DIR__ . '/lib/HireVoice/Neo4j/Annotation/ManyToMany.php';
$em = new HireVoice\Neo4j\EntityManager(array(
'transport' => 'curl', // or 'stream'
'host' => 'localhost',
'port' => 7474,
// 'username' => null,
// 'password' => null,
// 'proxy_dir' => '/tmp',
// 'debug' => true, // Force proxy regeneration on each request
// 'annotation_reader' => ... // Should be a cached instance of the doctrine annotation reader in production
));
/User.php
namespace Entity;
use HireVoice\Neo4j\Annotation as OGM;
use Doctrine\Common\Collections\ArrayCollection;
/**
* @OGM\Entity
*/
class User
{
/**
* @OGM\Auto
*/
protected $id;
/**
* @OGM\Property
* @OGM\Index
*/
protected $fullName;
function setFullName($fullname){
$this->fullname = $fullname;
}
}
/save.php
require 'bootstrap.php';
require 'User.php';
$repo = $em->getRepository('Entity\\User');
$jane = new User;
$jane->setFullName('Jane Doe');
$em->persist($jane);
$em->flush();
在生产中,我将自动加载实体类,现在我只需要它们。在浏览器中加载save.php时,会抛出这个错误:
Fatal error: Class 'User' not found in C:\htdocs\neo4j-php\ogm\save.php on line 7
我不知道为什么,因为在bootstrap.php 之后需要User.php 实体类。关于为什么的任何建议?提前致谢。
【问题讨论】:
标签: php doctrine-orm doctrine neo4j