I just installed neo4j server in Windows and am trying to connect with php. I have xampp running, installed neo4jphp with composer, and then tried to check the connection using the following script:
<?php
require('vendor/autoload.php');
$client = new Everyman\Neo4j\Client('localhost', 7474);
print_r($client->getServerInfo());
?>
Now, instead of showing server status, a fatal error occured like this:
Fatal error: Uncaught exception 'Everyman\Neo4j\Exception' with message 'Unable to retrieve server info [401]: Headers: Array ( [Date] => Wed, 27 May 2015 10:54:01 GMT [Content-Type] => application/json; charset=UTF-8 [WWW-Authenticate] => None [Content-Length] => 144 [Server] => Jetty(9.2.z-SNAPSHOT) ) Body: Array ( [errors] => Array ( [0] => Array ( [message] => No authorization header supplied. [code] => Neo.ClientError.Security.AuthorizationFailed ) ) ) ' in C:\xampp\htdocs\neo4j\vendor\everyman\neo4jphp\lib\Everyman\Neo4j\Command.php:116 Stack trace: #0 C:\xampp\htdocs\neo4j\vendor\everyman\neo4jphp\lib\Everyman\Neo4j\Command\GetServerInfo.php(53): Everyman\Neo4j\Command->throwException('Unable to retri...', 401, Array, Array) #1 C:\xampp\htdocs\neo4j\vendor\everyman\neo4jphp\lib\Everyman\Neo4j\Command.php(69): Everyman\Neo4j\Command\GetServerInfo->handleResult(401, Array, Array) #2 C:\xa in C:\xampp\htdocs\neo4j\vendor\everyman\neo4jphp\lib\Everyman\Neo4j\Command.php on line 116
How to solve this? Any help will be appreciated. Thanks in advance.
It will work. You just need to define the authorization credentials, for example like this:
Adjust the user/password accordingly('neo4j'/'neo4j' are default ones).
Another solution is to disable the requirement for authorization when accessing Neo4j. This can be done by editing Neo4j config file:
and setting to false the following flag:
Of course you need to remember about restarting the server afterwards.