laudis / graphaware-neo4j-bolt-legacy
Neo4j Bolt 二进制协议 PHP 驱动
5.1.0
2021-05-30 20:51 UTC
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-08-29 05:30:44 UTC
README
⚠️ 警告 ⚠️
这是一个遗留的API。该项目存在是为了让人们在现有项目中快速使用更新的neo4j版本。对于最新的驱动程序和最新功能,请访问neo4j php 客户端,在neo4j-php github 页面上。还有一个名为Bolt的底层驱动程序。
要求
- PHP ^7.0 || ^8.0
- Neo4j ^3.0 || ^4.0
sockets
扩展bcmath
扩展mbstring
扩展
安装
在依赖关系中添加该包
composer require laudis/graphaware-neo4j-bolt-legacy
设置驱动程序和创建会话
use GraphAware\Bolt\GraphDatabase; $driver = GraphDatabase::driver("bolt://localhost"); $session = $driver->session();
发送 Cypher 语句
$session = $driver->session(); $session->run("CREATE (n)"); $session->close(); // with parameters : $session->run("CREATE (n) SET n += {props}", ['name' => 'Mike', 'age' => 27]);
空数组
由于 PHP 中缺少集合类型,无法区分何时应将空数组视为等同于 Java List 或 Map 类型。
因此,您可以使用数组的包装器来保证类型安全
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 加密
为了启用 TLS 支持,您需要将配置选项设置为 REQUIRED
,以下是一个示例
$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();