我已经在https://github.com/graphaware/neo4j-php-client#installation-and-basic-usage和https://docs.graphenedb.com/docs/php上阅读了说明
虽然GrapheneDb文档中的这个示例可以工作,但它不使用GraphAware Neo4j PHP客户端,它使用Neo4j Bolt PHP:
// Example for Bolt
$config = \GraphAware\Bolt\Configuration::newInstance()
->withCredentials('user', 'pass')
->withTimeout(10)
->withTLSMode(\GraphAware\Bolt\Configuration::TLSMODE_REQUIRED);
$driver = \GraphAware\Bolt\GraphDatabase::driver('bolt://hobby-my-graph-db.dbs.graphenedb.com:24786', $config);
$client = $driver->session();我在任何地方都找不到可用的示例,我已经尝试了所有的方法;我已经反复检查了连接字符串,我已经尝试了http和螺栓,我已经从neo4j浏览器登录到数据库,所以我知道凭据肯定是正确的。
下面是我的代码:
/* GraphAware\Bolt\Configuration */
$config = Configuration::create()
->withCredentials('user', 'pass')
->withTimeout(10)
->withTLSMode(Configuration::TLSMODE_REQUIRED);
/* GraphAware\Neo4j\Client\ClientBuilder */
$client = ClientBuilder::create()
->addConnection('bolt', 'bolt://hobby-my-graph-db.dbs.graphenedb.com:24787', $config)
->build();
$result = $client->run("CREATE (n:Person {name: 'Bob'}) RETURN id(n)");当我尝试运行查询时,我得到了:
Exception 'GraphAware\Bolt\Exception\HandshakeException' with message 'Error receiving data'
in /path-to-project/vendor/graphaware/neo4j-bolt/src/Driver.php:165有没有人有一个完整的使用graphaware/ne4j-php- GrapheneDb的客户端连接示例?
发布于 2020-08-08 01:21:56
螺栓驱动程序:由于某些原因,GraphAware\Neo4j\Client\Connection\Connection.php不使用您传递给GraphAware\Neo4j\Client\ClientBuilder->addConnection()方法的配置(?)。它将重新构建配置,省略除用户名和密码之外的所有内容。所以,如果你的连接需要像我一样的TLS模式,如果不改变源,它将永远不会工作。
在buildDriver()方法内部的GraphAware\Neo4j\Client\Connection\Connection.php:180中,我只使用我传入的配置,它是$this->config,而不是他们为您重新构建的配置。按其应有的方式工作。
修改后的代码看起来像:$this->driver = BoltGraphDB::driver($uri, $this->config);
(graphaware/ne4j-php-client 4.8.5)
发布于 2020-10-13 01:03:37
实际上,只是不要使用graphenedb,它太糟糕了。只需使用https://neo4j.com/cloud/aura即可。工作时不会浪费任何时间。
https://stackoverflow.com/questions/63293359
复制相似问题