Reputation: 642
I am a Beginner of Neo4J and wanted to use with php.
1. Downloaded Neo4Jphp https://github.com/jadell/Neo4jPHP
2. Unzipped at htdocs/abc/neo4php
3. Used Below code (at htdocs/abc/index.php) but getting ERROR -
Fatal error: Class 'neo4php\lib\Everyman\Neo4j\Client' not found in D:\xampp\htdocs\abc\index.php on line 14
Code-
<!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>
How to solve the issue and access Neo4J using PHP, Is there any video tutorial for Neo4JPhp
Upvotes: 2
Views: 1737
Reputation: 1555
You aren't including the library anywhere. In PHP, you can't just use
classes, you have to include a file which contains that class, or use an autoloader that maps class names to file names (autoloading is the preferred way to do it.)
I suggest installing the library with Composer. There are instructions for this on the neo4jphp wiki: https://github.com/jadell/neo4jphp/wiki/Getting-started. (You will need to install Composer first; instructions available here: https://getcomposer.org/)
Then, in your file, you can do:
<?php
require('vendor/autoload.php');
use Everyman\Neo4j\Client,
Everyman\Neo4j\Transport,
Everyman\Neo4j\Node,
Everyman\Neo4j\Relationship;
// The rest of your code
Upvotes: 2