Reputation: 73
So I installed Neo4J alongside the Neo4J-PHP-Client found on GitHub here : https://github.com/graphaware/neo4j-php-client
I can query my database through the Desktop App and everything I do takes effect. I managed to connect to my database through PHP successfully, no errors at all. The problem arises when I try to run a query through PHP, it doesn't work at all, despite the very same query working perfectly if I run it through the Neo4J Desktop App.
Here's my code snippet, also I used the query example given in the GitHub post of Neo4J-PHP-Client :
<?php
require_once './vendor/autoload.php';
use GraphAware\Neo4j\Client\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('default', 'http://neo4j:parola@localhost:7474')
->build();
$client->run('CREATE (n:Person)');
?>
The error I get is :
Fatal error: Uncaught Http\Client\Common\Exception\ClientErrorException: Unsupported Media Type in C:\xampp\htdocs\licenta\vendor\php-http\client-common\src\Plugin\ErrorPlugin.php:72
Stack trace: #0 C:\xampp\htdocs\licenta\vendor\php-http\client-common\src\Plugin\ErrorPlugin.php(54):
Http\Client\Common\Plugin\ErrorPlugin->transformResponseToException(Object(GuzzleHttp\Psr7\Request), Object(GuzzleHttp\Psr7\Response)) #1
C:\xampp\htdocs\licenta\vendor\php-http\httplug\src\Promise\HttpFulfilledPromise.php(34):
Http\Client\Common\Plugin\ErrorPlugin->Http\Client\Common\Plugin\{closure}(Object(GuzzleHttp\Psr7\Response)) #2
C:\xampp\htdocs\licenta\vendor\php-http\client-common\src\Plugin\ErrorPlugin.php(55): Http\Client\Promise\HttpFulfilledPromise->then(Object(Closure)) #3
C:\xampp\htdocs\licenta\vendor\php-http\client-common\src\PluginClient.php(161): Http\Client\Common\Plugin\ErrorPlugin->handleRequest(Object(GuzzleHttp\Psr7\Request), Object(Closure), Object(Closure)) #4
C:\xampp\htdocs\licenta\vendor\php-http\client-common\s in C:\xampp\htdocs\licenta\vendor\php-http\client-common\src\Plugin\ErrorPlugin.php on line 72
I really can't wrap my head around it, any help is greatly appreciated. Thanks in advance!
Upvotes: 1
Views: 226
Reputation: 545
If you want to use Neo4j from PHP you have to use Bolt library https://github.com/neo4j-php/Bolt
Also here is a guide for beginners where you will find all important informations https://ko-fi.com/post/Complete-guide-for-PHP-Neo4j-Q5Q2DT98D
Upvotes: 0