GraphAware PHP Client

We use the GraphAware PHP Client at Graph Story for many applications. It's very powerful and well-supported.

You can install it with composer:

composer require graphaware/neo4j-php-client:^4.0

Use it in your code like so:

<?php
require_once "vendor/autoload.php";

use GraphAware\Neo4j\Client\ClientBuilder;

$client = ClientBuilder::create()
    ->addConnection("bolt", "bolt://username:password@your-domain.provider.graphstory.com:7687")
    ->build();
$query = "MATCH (n:Person)-[:FOLLOWS]->(friend) RETURN n.name, collect(friend) as friends";
$result = $client->run($query);

foreach ($result->getRecords() as $record) {
    echo sprintf(
        "Person name is : %s and has %d number of friends",
        $record->value('name'),
        count($record->value('friends'))
    );
}

Other PHP libraries

More information on using Neo4j with PHP


Did this answer your question?