How do you connect to GrapheneDb using graphaware/neo4j-php-client?

I have read the instructions at both and

While this example from the GrapheneDb docs does work, it does not use GraphAware Neo4j PHP Client, it uses Neo4j Bolt PHP:

// Example for Bolt
$config = \GraphAware\Bolt\Configuration::newInstance()
->withCredentials('user', 'pass')

$driver = \GraphAware\Bolt\GraphDatabase::driver('bolt://', $config);
$client = $driver->session();

I can't find a working example anywhere, I have tried all kinds of things; I have double and triple checked the connection strings, I have tried http as well as bolt, I have logged into the database from neo4j browser so I know the credentials must be ok.

This is what my code looks like:

/* GraphAware\Bolt\Configuration */
$config = Configuration::create()
->withCredentials('user', 'pass')
/* GraphAware\Neo4j\Client\ClientBuilder */
$client = ClientBuilder::create()
->addConnection('bolt', 'bolt://', $config)
$result = $client->run("CREATE (n:Person {name: 'Bob'}) RETURN id(n)");

When I try to run the query I get:

Exception 'GraphAware\Bolt\Exception\HandshakeException' with message 'Error receiving data'
in /path-to-project/vendor/graphaware/neo4j-bolt/src/Driver.php:165

Does anyone have a complete working connection example to GrapheneDb using graphaware/neo4j-php-client?

1 answer

  • answered 2020-08-07 17:21 dataskills

    The bolt driver: For some reason GraphAware\Neo4j\Client\Connection\Connection.php does not use the configuration you pass in to the GraphAware\Neo4j\Client\ClientBuilder->addConnection() method (???). It rebuilds the configuration, leaving out everything except for the username and password. So, if your connection requires TLS mode like mine, it will never work without altering the source.

    At GraphAware\Neo4j\Client\Connection\Connection.php:180 inside the buildDriver() method I simply use the configuration I passed in which is $this->config instead of the one they rebuild for you. Works as it should.

    After alteration it looks like: $this->driver = BoltGraphDB::driver($uri, $this->config);

    (graphaware/neo4j-php-client 4.8.5)