2017 © Pedro Peláez
 

package php-cypher-query-builder

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

image

paulmozo/php-cypher-query-builder

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  • Tuesday, July 10, 2018
  • by pmozo
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

php-cypher-query-builder

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J, (*1)

NOTES

  • This is a work in progress and there is still a lot to be done

Making cypher queries easily using the query builder

$client = new Moozla\QueryBuilder\Client();

$client
  ->match('Person', 'person')
  ->match('LIKES')
  ->match('Movie', 'movie')
  ->where('movie', 'name', "=", 'Taxi Driver')
  ->return('movie');

echo (string)$client;

Will output the string:, (*2)

MATCH (person:Person)-[:LIKES]-(movie:Movie) WHERE movie.name = "Taxi Driver" RETURN movie, (*3)

This project makes walking a graph easy. One of the main benefits is that it automatically figures out whether it needs to match a Node or a Relationship., (*4)

Running the tests

./vendor/bin/phpunit tests/, (*5)

To do on this project

  • Support more operators for the where clause
  • ~Add more clauses such as "SET", "CREATE" and "DELETE"~
  • ~Add Directional relationships support~
  • More exceptions when invalid Cypher is detected
  • ~Make this project available via packagist~

Examples

For a full list of examples look at the client tests found in tests/ClientTests/, (*6)

Match Node-relation-Node and return all 3

$client = new Moozla\QueryBuilder\Client();

$client
  ->match('Person', 'person')
  ->match('LIKES', 'likes')
  ->match('Movie', 'movie')
  ->return('person')
  ->return('likes')
  ->return('movie');

echo (string)$client;

Will output the string:, (*7)

MATCH (person:Person)-[likes:LIKES]-(movie:Movie) RETURN person, likes, movie, (*8)

Match Node then add custom CYPHER to all clauses

$client = new Moozla\QueryBuilder\Client();

$client
  ->match('Person', 'person')
  ->appendToMatch('-[]->(:CustomMatch)')
  ->appendToWhere('(person)-[:KNOWS]-({name: 'Jeff'})')
  ->appendToReturn('count(person)');

echo (string)$client;

Will output the string:, (*9)

MATCH (person:Person)-[]->(:CustomMatch) WHERE (person)-[:KNOWS]-({name: 'Jeff'}) RETURN count(person), (*10)

Note: All of the 'appendTo' methods will simply append the given string to the specified clause allowing for CYPHER not directly supported through the other query builder methods, (*11)

Multi Match

Sometimes with Cypher you need to match multiple parts of the graph before joining them. The query builder supports this, (*12)

$client = new Moozla\QueryBuilder\Client();
$client
  ->match('Person', 'person')
  ->endMatch()
  ->match('Movie', 'movie')
  ->match('DIRECTED_BY')
  ->match('Director', 'director')
  ->where('director', 'name', '=', 'Ms Director')
  ->return('movie')
  ->return('person');

echo (string)$client;

Will output the following:, (*13)

MATCH (person:Person) MATCH (movie:Movie)-[:DIRECTED_BY]-(director:Director) WHERE director.name = "Ms Director" RETURN movie, person, (*14)

The Versions

10/07 2018

dev-master

9999999-dev

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

10/07 2018

0.11

0.11.0.0

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

10/07 2018

0.1

0.1.0.0

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

10/07 2018

dev-additional-clauses

dev-additional-clauses

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

05/06 2018

dev-multiple-match-support

dev-multiple-match-support

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

04/06 2018

dev-left-and-right-match-support

dev-left-and-right-match-support

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

30/05 2018

dev-custom_appends

dev-custom_appends

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j

29/05 2018

dev-namespace-change

dev-namespace-change

A PHP library for generating Cypher queries to be used with Graph databases such as Neo4J

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

by Paul Mozo

query cypher neo4j