Today i have written first basic program for Neo4j from PHP. This was basically done to check out if we could use Neo4j in our new project from PHP by using Neo4jPhp. https://github.com/jadell/neo4jphp
here is my code
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
include 'neo4jphp.phar';
echo "Hello World!";
// Connecting to the default port 7474 on localhost
$client = new Everyman\Neo4j\Client();
$queryString =
"MATCH (n)".
"RETURN n";
$query = new Everyman\Neo4j\Cypher\Query($client, $queryString);
$result = $query->getResultSet();
foreach ($result as $row) {
echo $row['n']->getProperty('name') . "\n";
}
?>
</body>
</html>
Now here i am just retrieving all the nodes with their property. Pretty simple.
if i run this from graphical console of Neo4j, it takes 86 ms. I have only 200 nodes and almost same property.
match (n)
return n
Returned 50 rows in 86 ms
If i run this from above PHP file, it takes 2-4 seconds in total to dump data in browser. Neo4j is running in same machine.
Please note that i have not done any changes in the configuration of both PHP and Neo4j. Everything is default. Please tell me if this is the expected behaviour of Neo4j with PHP or something is really wrong with my code or configuration.
Thanks a lot
Can you debug and measure what the REST request to neo4j server is actually taking? It should be something like 86ms, rest should be in the PHP code? Also, please use parameters so you don't have the overhead of creating query plans for repeating cypher queries.