danve / php-cypher-dsl

A query builder for the Cypher query language written in PHP

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

php-cypher-dsl

Build status

The php-cypher-dsl library provides a way to construct advanced Cypher queries in an object-oriented and type-safe manner.

Documentation

The documentation can be found on the wiki here.

Installation

Requirements

php-cypher-dsl requires PHP 7.4 or greater; using the latest version of PHP is highly recommended.

Installation through Composer

You can install php-cypher-dsl through composer by running the following command:

composer require "wikibase-solutions/php-cypher-dsl"

Example

To construct a query to find all of Tom Hanks' co-actors, you can use the following code:

$tom = Query::node("Person")->withProperties(["name" => Query::literal("Tom Hanks")]);
$coActors = Query::node();

$statement = Query::new()
    ->match($tom->relationshipTo(Query::node(), "ACTED_IN")->relationshipFrom($coActors, "ACTED_IN"))
    ->returning($coActors->property("name"))
    ->build();

$this->assertStringMatchesFormat("MATCH (:Person {name: 'Tom Hanks'})-[:`ACTED_IN`]->()<-[:`ACTED_IN`]-(%s) RETURN %s.name", $statement);

About

A query builder for the Cypher query language written in PHP

License:GNU General Public License v2.0


Languages

Language:PHP 100.0%