PHPackages                             wikibase-solutions/php-cypher-dsl - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. wikibase-solutions/php-cypher-dsl

ActiveLibrary[Database &amp; ORM](/categories/database)

wikibase-solutions/php-cypher-dsl
=================================

A query builder for the Cypher query language

7.0.0(3mo ago)1853.4k↓14.9%5[7 issues](https://github.com/neo4j-php/php-cypher-dsl/issues)3MITPHPPHP &gt;=8.1CI passing

Since Oct 13Pushed 3mo ago6 watchersCompare

[ Source](https://github.com/neo4j-php/php-cypher-dsl)[ Packagist](https://packagist.org/packages/wikibase-solutions/php-cypher-dsl)[ Docs](https://wikibase-solutions.com)[ RSS](/packages/wikibase-solutions-php-cypher-dsl/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (5)Versions (51)Used By (3)

php-cypher-dsl
==============

[](#php-cypher-dsl)

The `php-cypher-dsl` library provides a way to construct Cypher queries in a type-safe manner.

Documentation
-------------

[](#documentation)

[The documentation can be found on the wiki here.](https://github.com/WikibaseSolutions/php-cypher-dsl/wiki)

Installation
------------

[](#installation)

### Requirements

[](#requirements)

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

### Installation through Composer

[](#installation-through-composer)

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

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

```

Contributing
------------

[](#contributing)

Please refer to [CONTRIBUTING.md](https://github.com/neo4j-php/php-cypher-dsl/blob/main/.github/CONTRIBUTING.md) for information on how to contribute to this project.

Example
-------

[](#example)

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

```
use function WikibaseSolutions\CypherDSL\node;
use function WikibaseSolutions\CypherDSL\query;

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

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

This produces the following Cypher query (where `$1` is a random variable name):

```
MATCH (:Person {name: 'Tom Hanks'})-[:ACTED_IN]->()
