laudis / graphaware-neo4j-bolt-legacy
Neo4j Bolt Binary Protocol PHP Driver
Requires
- php: ^7.0 || ^8.0
- ext-bcmath: *
- ext-mbstring: *
- graphaware/neo4j-common: ^3.4
- laudis/neo4j-php-client: v2.0.x-dev
- myclabs/php-enum: ^1.4
- stefanak-michal/bolt: ^2.3
- symfony/event-dispatcher: ^2.7|^3.0|^4.0
Requires (Dev)
- behat/behat: ~3.0.4
- phpunit/phpunit: ^9.5.4
- symfony/stopwatch: ^2.7
- dev-master
- 55.x-dev
- 5.1.0
- 2.1.0
- 2.0.0
- 1.11.0
- 1.10.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.1
- 1.7.0
- 1.6.1
- 1.6.0
- 1.5.8
- 1.5.7
- 1.5.6
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.7
- 1.0.6
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-protocol-v2
- dev-collections
- dev-fix/marker-d6
- dev-ssl
- dev-issue2
- dev-m5
- dev-socket-perf
- dev-unpack-stream
- dev-tls
This package is auto-updated.
Last update: 2024-11-29 06:04:33 UTC
README
⚠️ Warning ⚠️
This is a legacy api. This project exists to ️allow people to quickly get up and running with newer versions of neo4j in existing projects. For the newest drivers and latest features, please visit the neo4j php client on the neo4j-php github page. There is also a lower level driver available under the name Bolt
Requirements:
- PHP ^7.0 || ^8.0
- Neo4j ^3.0 || ^4.0
sockets
extensionbcmath
extensionmbstring
extension
Installation
Require the package in your dependencies :
composer require laudis/graphaware-neo4j-bolt-legacy
Setting up a driver and creating a session
use GraphAware\Bolt\GraphDatabase; $driver = GraphDatabase::driver("bolt://localhost"); $session = $driver->session();
Sending a Cypher statement
$session = $driver->session(); $session->run("CREATE (n)"); $session->close(); // with parameters : $session->run("CREATE (n) SET n += {props}", ['name' => 'Mike', 'age' => 27]);
Empty Arrays
Due to lack of Collections types in php, there is no way to distinguish when an empty array should be treated as equivalent Java List or Map types.
Therefore you can use a wrapper around arrays for type safety :
use GraphAware\Common\Collections; $query = 'MERGE (n:User {id: {id} }) WITH n UNWIND {friends} AS friend MERGE (f:User {id: friend.name}) MERGE (f)-[:KNOWS]->(n)'; $params = ['id' => 'me', 'friends' => Collections::asList([])]; $this->getSession()->run($query, $params); // Or $query = 'MERGE (n:User {id: {id} }) WITH n UNWIND {friends}.users AS friend MERGE (f:User {id: friend.name}) MERGE (f)-[:KNOWS]->(n)'; $params = ['id' => 'me', 'friends' => Collections::asMap([])]; $this->getSession()->run($query, $params);
TLS Encryption
In order to enable TLS support, you need to set the configuration option to REQUIRED
, here an example :
$config = \GraphAware\Bolt\Configuration::newInstance() ->withCredentials('bolttest', 'L7n7SfTSj0e6U') ->withTLSMode(\GraphAware\Bolt\Configuration::TLSMODE_REQUIRED); $driver = \GraphAware\Bolt\GraphDatabase::driver('bolt://hobomjfhocgbkeenl.dbs.graphenedb.com:24786', $config); $session = $driver->session();