나는 최근에이 Doctrine2 style Neo4j wrapper으로 테스트를 마쳤습니다. 전에 Doctrine을 사용 해본 적은 없지만 Github 페이지와 Doctrine 문서의 훌륭한 예에서 벗어나 특정 지점을 통과하지 못했습니다. Neo4j-PHP-OGM 라이브러리를 추출하고, Composer로 Doctrine2를 다운로드하고, bootstrap.php
내에 EntityManager를 절차 적으로 (테스트 용으로) 포함 시켰습니다.Neo4j 및 Doctrine2 스타일 래퍼
/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();
, 나는 지금, 엔티티 클래스를 자동 로딩됩니다 나는 단지 그들을 필요로하고있다.
Fatal error: Class 'User' not found in C:\htdocs\neo4j-php\ogm\save.php on line 7
User.php
엔티티 클래스가 bootstrap.php
후 요구되고 있기 때문에 이유를 잘 모르겠어요 : 브라우저에서 save.php
를로드 할 때,이 오류가 발생합니다. 왜 그런가? 미리 감사드립니다.
감사합니다. 전체 클래스 경로를 지정해야했습니다. – Dan