请教neo4j+PHP8.3.7的问题
分别安装了两个库
composer require neoxygen/neoclient
composer require "graphaware/neo4j-php-client:^4.0"
graphaware代码:
require_once 'vendor/autoload.php';
use GraphAware\Neo4j\Client\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('neo4j',"http://neo4j:密码@192.168.1.196:7474")
->build();
$query="MATCH (n) RETURN n";
try {
$result = $client->run($query);
} catch (\Exception $e) {
// 处理异常
echo "查询执行出错: ", $e->getMessage();
}
neoclient代码:
require __DIR__ .'/vendor/autoload.php';
use Neoxygen\NeoClient\ClientBuilder;
$client = ClientBuilder::create()
->addConnection('default', 'http', 'localhost', 7474, true, 'neo4j', '密码')
->setAutoFormatResponse(true)
->setDefaultTimeout(200)
->build();
$version = $client->getNeoClientVersion();
echo "<br>版本号:".$version; //可以返回版本号
try {
$query = 'match (n) return n';
$result = $client->sendCypherQuery($query)->getResult();
} catch (\Exception $e) {
// 处理异常
echo "查询执行出错: ", $e->getMessage();
}
两种方式都是返回:
查询执行出错: Client error: POST http://neo4j:***@192.168.1.196:7474/db/data/transaction/commit
resulted in a 404 Not Found
response: {"errors":[{"code":"Neo.ClientError.Request.Invalid","message":"Not Found"}]}
哪位朋友用过php连neo4j,看看是什么问题?