Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kjdev/php-redis-graph
RedisGraph PHP Client
https://github.com/kjdev/php-redis-graph
Last synced: 25 days ago
JSON representation
RedisGraph PHP Client
- Host: GitHub
- URL: https://github.com/kjdev/php-redis-graph
- Owner: kjdev
- License: mit
- Created: 2018-10-24T06:14:34.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-01-16T21:50:17.000Z (almost 3 years ago)
- Last Synced: 2024-12-15T09:24:01.936Z (26 days ago)
- Language: PHP
- Size: 39.1 KB
- Stars: 40
- Watchers: 6
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
RedisGraph PHP Client
=====================[![Build Status](https://travis-ci.org/kjdev/php-redis-graph.svg?branch=master)](https://travis-ci.org/kjdev/php-redis-graph)
[RedisGraph](https://github.com/RedisGraph/RedisGraph)
Install
-------``` sh
composer require kjdev/redis-graph
```As Redis's client library, use either.
- `predis/predis`
> `composer require predis/predis`
- `ext-redis`
> `pecl install redis`
Example
-------``` php
require __DIR__ . '/vendor/autoload.php';use Redis\Graph;
use Redis\Graph\Node;
use Redis\Graph\Edge;$redis = new Predis\Client('redis://127.0.0.1:6379/');
// OR
// $redis = new Redis();
// $redis->connect('127.0.0.1', 6379);$graph = new Graph('social', $redis);
$john = new Node('person', [
'name' => 'John Doe',
'age' => 33,
'gender' => 'male',
'status' => 'single'
]);
$graph->addNode($john);$japan = new Node('country', [
'name' => 'Japan'
]);
$graph->addNode($japan);$edge = new Edge($john, $japan, 'visited', ['purpose' => 'pleasure']);
$graph->addEdge($edge);$graph->commit();
$query = 'MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country) RETURN p.name, p.age, v.purpose, c.name';
$result = $graph->query($query);
// Print resultset
$result->prettyPrint();// Iterate through resultset
while ($row = $result->fetch()) {
var_dump($row);
}
// var_dump($result->fetchAll());// All done, remove graph.
$graph->delete();
```