0

我已经阅读了https://github.com/graphaware/neo4j-php-client#installation-and-basic-usagehttps://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 和 bolt,我已经从 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/neo4j-php-client 提供到 GrapheneDb 的完整工作连接示例?

4

2 回答 2

0

实际上,只是不要使用graphenedb,它很烂。只需使用https://neo4j.com/cloud/aura。无需任何操作即可工作。

于 2020-10-12T17:03:36.507 回答
0

螺栓驱动器:由于某种原因GraphAware\Neo4j\Client\Connection\Connection.php,不使用您传递给GraphAware\Neo4j\Client\ClientBuilder->addConnection()方法的配置(???)。它重建配置,除了用户名和密码之外的所有内容都被忽略。因此,如果您的连接需要像我这样的 TLS 模式,那么如果不更改源,它将永远无法工作。

在方法GraphAware\Neo4j\Client\Connection\Connection.php:180内部,buildDriver()我只是使用我传入的配置,$this->config而不是他们为您重建的配置。正常工作。

改造后的样子:$this->driver = BoltGraphDB::driver($uri, $this->config);

(graphaware/neo4j-php-client 4.8.5)

于 2020-08-07T17:21:56.247 回答