我已经阅读了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 和 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 的完整工作连接示例?