graphaware / neo4j-response-formatter
此包已被废弃,不再维护。未建议替代包。
NeoClient 的响应格式化器
1.2.0
2015-08-06 21:11 UTC
Requires
- psr/http-message: ^1.0
Requires (Dev)
- neoxygen/neoclient: ^3.2
- phpspec/prophecy: ^1.4
- phpunit/phpunit: ^4.7
README
基于 Neo4j Rest API Http 响应格式的高级格式化。
特性
- 由 PSR-7 Http 消息启动的响应对象
- 带有节点和关系对象的内存图表示
- 表格格式
- 智能获取器
用法
在 NeoClient 中,当前的用法是可选的,以避免向后不兼容的更改,这将成为 NeoClient v4 中的默认格式化服务。
启用 GraphAware 的格式化服务
$client = ClientBuilder::create() ->addDefaultLocalConnection() ->setAutoFormatResponse(true) ->enableNewFormattingService() ->build();
从现在起,你将收到的所有响应都将为 GraphAware\NeoClient\Formatter\Response
的实例。
获取结果
$response = $client->sendCypherQuery('MATCH (n) OPTIONAL MATCH (n)-[r]-() RETURN n,r'); // here we only expect one result $result = $response->getResult(); // The result object holds nodes, relationships and table format $nodes = $result->getNodes(); $relationships = $result->getRelationships(); // If you expect multiple results, like for preparedTransactions $results = $response->getResults(); // Using the table $table = $result->getTable(); $rows = $table->getRows(); print_r($rows);
更多文档即将推出...
许可 MIT