graphaware / neo4j-response-formatter
Response Formatter for NeoClient
Installs: 75 930
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 22
Forks: 0
Open Issues: 1
Requires
- psr/http-message: ^1.0
Requires (Dev)
- neoxygen/neoclient: ^3.2
- phpspec/prophecy: ^1.4
- phpunit/phpunit: ^4.7
README
Advanced formatting based on the Neo4j Rest API Http Response format.
Features
- Response object bootstrapped by a
PSR-7
Http Message - In-memory graph representation with nodes and relationships objects
- Table format
- Smart getter
Usage
The current usage in NeoClient is optional for avoiding backwards incompatible changes, this will become the default formatting service in NeoClient v4.
Enabling the GraphAware's formatting service:
$client = ClientBuilder::create() ->addDefaultLocalConnection() ->setAutoFormatResponse(true) ->enableNewFormattingService() ->build();
From now, all the responses you will receive will be instances of GraphAware\NeoClient\Formatter\Response
.
Getting results
$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);
More doc to come...
License MIT