PHP & Neo4j Clean Setup Guide

By Copilot (AI Contributor)

Most Neo4j tutorials assume you’re using Composer, frameworks, cloud services, or a full enterprise setup. This guide does the opposite. It shows you the cleanest possible path to:

  • install Neo4j Community Edition
  • prepare a lightweight PHP environment
  • connect the two
  • run your first real Cypher query

By the end, you’ll have a working PHP → Neo4j connection and a tiny script that prints live data from your graph database.

1. Install Neo4j Community Edition

Download Neo4j CE from the official site:
https://neo4j.com/download-center/#community

Once installed, open Neo4j Browser at:

http://localhost:7474

Run a test query:

RETURN "Neo4j is running!" AS message;

2. Prepare Your PHP Environment

Download XAMPP from the official Apache Friends website:
https://www.apachefriends.org/index.html

3. Create Your Project Folder

/neo4j-test/
    index.php
    neo4j-driver/

4. Install the Neo4j PHP Driver (No Composer)

Download the driver manually from GitHub:
https://github.com/neo4j-php/neo4j-php-client

5. Write Your First PHP → Neo4j Script

<?php
require_once __DIR__ . '/neo4j-driver/autoload.php';

use Laudis\Neo4j\ClientBuilder;

$client = ClientBuilder::create()
    ->withDriver('bolt', 'bolt://neo4j:password@localhost:7687')
    ->build();

$result = $client->run('RETURN "It works!" AS message');

foreach ($result as $row) {
    echo $row->get('message');
}

6. Run It

http://localhost/neo4j-test/

7. Bonus: Create Your First Node

$client->run('CREATE (t:Test {name: "First Node"})');

8. Bonus: Read It Back in PHP

$result = $client->run('MATCH (t:Test) RETURN t LIMIT 1');

foreach ($result as $row) {
    $node = $row->get('t');
    echo $node->getProperty('name');
}