graphaware / neo4j-bolt
Neo4j Bolt Binary Protocol PHP Driver
Installs: 732 065
Dependents: 7
Suggesters: 0
Security: 0
Stars: 43
Watchers: 22
Forks: 23
Open Issues: 12
Requires
- php: >= 5.6
- ext-bcmath: *
- ext-mbstring: *
- graphaware/neo4j-common: ^3.4
- myclabs/php-enum: ^1.4
- symfony/event-dispatcher: ^2.7|^3.0|^4.0
Requires (Dev)
- behat/behat: ~3.0.4
- phpunit/phpunit: ^4.8
- symfony/stopwatch: ^2.7
- dev-master
- 55.x-dev
- 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 not auto-updated.
Last update: 2020-08-21 20:12:34 UTC
README
PHP low level Driver for Neo4j's Bolt Remoting Protocol
References :
- PHP Client embedding Bolt along with the http driver (recommended way of using Neo4j in PHP) : https://github.com/graphaware/neo4j-php-client
- Neo4j 3.0 : http://neo4j.com/docs
Requirements:
- PHP5.6+
- Neo4j3.0
- PHP Sockets extension available
bcmath
extensionmbstring
extension
Installation
Require the package in your dependencies :
composer require graphaware/neo4j-bolt
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();
License
Copyright (c) 2015-2016 GraphAware Ltd
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.