Neo4Jphp的安装和工作初学者

时间:2014-03-02 18:13:37

标签: php neo4j install neo4jphp

我是Neo4J的初学者,想和php一起使用 1.下载Neo4Jphp https://github.com/jadell/Neo4jPHP
2.解压缩到htdocs / abc / neo4php
3.使用下面的代码(在htdocs / abc / index.php)但得到错误 -

Fatal error: Class 'neo4php\lib\Everyman\Neo4j\Client' not found in D:\xampp\htdocs\abc\index.php on line 14

代码 -

<!DOCTYPE html>
<html>
<body>

<h1>Neo4J</h1>

<?php

use neo4php\lib\Everyman\Neo4j\Client,
    neo4php\lib\Everyman\Neo4j\Transport,
    neo4php\lib\Everyman\Neo4j\Node,
    neo4php\lib\Everyman\Neo4j\Relationship;

$client = new Client(new Transport('localhost', 7474));
$keanu = new Node($client);
$keanu->setProperty('name', 'Keanu Reeves')->save();
$laurence = new Node($client);
$laurence->setProperty('name', 'Laurence Fishburne')->save();
$jennifer = new Node($client);
$jennifer->setProperty('name', 'Jennifer Connelly')->save();
$kevin = new Node($client);
$kevin->setProperty('name', 'Kevin Bacon')->save();

$matrix = new Node($client);
$matrix->setProperty('title', 'The Matrix')->save();
$higherLearning = new Node($client);
$higherLearning->setProperty('title', 'Higher Learning')->save();
$mysticRiver = new Node($client);
$mysticRiver->setProperty('title', 'Mystic River')->save();

?>

</body>
</html>

如何解决问题并使用PHP访问Neo4J,Neo4JPhp是否有任何视频教程

1 个答案:

答案 0 :(得分:2)

您没有在任何地方加入图书馆。在PHP中,您不能只是use类,您必须包含一个包含该类的文件,或者使用将类名映射到文件名的自动加载器(自动加载是首选方法。)

我建议使用Composer安装库。在neo4jphp wiki上有关于此的说明:https://github.com/jadell/neo4jphp/wiki/Getting-started。 (您需要先安装Composer;此处提供说明:https://getcomposer.org/

然后,在您的文件中,您可以执行以下操作:

<?php
require('vendor/autoload.php');

use Everyman\Neo4j\Client,
    Everyman\Neo4j\Transport,
    Everyman\Neo4j\Node,
    Everyman\Neo4j\Relationship;

// The rest of your code