Skip to content

Repository files navigation

RedisGraph PHP Client

Build Status

RedisGraph

Install

composer require kjdev/redis-graph

As Redis's client library, use either.

  • predis/predis

    composer require predis/predis

  • ext-redis

    pecl install redis

Example

require__DIR__ . '/vendor/autoload.php';
useRedis\Graph;
useRedis\Graph\Node;
useRedis\Graph\Edge;
$redis = newPredis\Client('redis://127.0.0.1:6379/');
// OR// $redis = new Redis();// $redis->connect('127.0.0.1', 6379);$graph = newGraph('social', $redis);
$john = newNode('person', [
'name' => 'John Doe',
'age' => 33,
'gender' => 'male',
'status' => 'single'
]);
$graph->addNode($john);
$japan = newNode('country', [
'name' => 'Japan'
]);
$graph->addNode($japan);
$edge = newEdge($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 resultsetwhile ($row = $result->fetch()) {
var_dump($row);
}
// var_dump($result->fetchAll());// All done, remove graph.$graph->delete();

About

RedisGraph PHP Client

Resources

Stars

44 stars

Watchers

6 watching

Forks

Releases

Packages

Used by

Contributors

Languages