PHPackages                             signalnorth/laravel-neo4j - 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. signalnorth/laravel-neo4j

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

signalnorth/laravel-neo4j
=========================

Neo4j database driver for Laravel with migration support, query builder, and Eloquent-style models

1.0.2(10mo ago)15MITPHPPHP ^8.2|^8.3

Since Jul 8Pushed 10mo ago1 watchersCompare

[ Source](https://github.com/Signal-North/laravel-neo4j)[ Packagist](https://packagist.org/packages/signalnorth/laravel-neo4j)[ Docs](https://github.com/signalnorth/laravel-neo4j)[ RSS](/packages/signalnorth-laravel-neo4j/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (9)Versions (3)Used By (0)

Laravel Neo4j
=============

[](#laravel-neo4j)

[![Latest Version](https://camo.githubusercontent.com/0075b487554ae0a93444e570e702ead7b698b5543a850815765dcb36eff6abc1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7369676e616c6e6f7274682f6c61726176656c2d6e656f346a2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signalnorth/laravel-neo4j)[![Total Downloads](https://camo.githubusercontent.com/f2abc28e94b01a80334c1b05449f63b1c57860ca67434a225aa0e01cf1d9f30c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7369676e616c6e6f7274682f6c61726176656c2d6e656f346a2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signalnorth/laravel-neo4j)[![License](https://camo.githubusercontent.com/8469db9e0d47e8023dfb949952902498a0406ae7251d0b0d700f142148232245/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7369676e616c6e6f7274682f6c61726176656c2d6e656f346a2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/signalnorth/laravel-neo4j/LICENCE.md)

A comprehensive Neo4j integration for Laravel, providing a complete database driver with migration support, query builder, and Eloquent-style models for graph databases.

Features
--------

[](#features)

- **Full Laravel Integration** - Works seamlessly with Laravel's database layer
- **Migration Support** - Version control your graph database schema
- **Query Builder** - Fluent interface for building Cypher queries
- **Eloquent-style Models** - Familiar syntax for graph operations
- **Artisan Commands** - Manage your Neo4j database from the CLI
- **Schema Builder** - Create constraints and indexes programmatically
- **Transaction Support** - Full ACID compliance with rollback capabilities
- **Performance Optimised** - Connection pooling and query caching

Requirements
------------

[](#requirements)

- PHP 8.2 or 8.3
- Laravel 12.x (fully compatible)
- Neo4j 4.4+ or 5.0+
- ext-bcmath and ext-sockets PHP extensions

> **Note**: This package has been specifically optimized for Laravel 12 and includes all necessary compatibility updates for the latest framework features.

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

[](#installation)

Install the package via Composer:

```
composer require signalnorth/laravel-neo4j
```

> **Laravel 12 Compatibility**: This package has been specifically updated for Laravel 12 with all necessary compatibility fixes including updated grammar constructors, method signatures, and event system integration.

Run the installation command:

```
php artisan neo4j:install
```

This will:

- Publish the configuration file
- Create the Neo4j migrations directory
- Add environment variables to `.env.example`

Configuration
-------------

[](#configuration)

Add your Neo4j connection details to your `.env` file:

```
NEO4J_SCHEME=bolt
NEO4J_HOST=localhost
NEO4J_PORT=7687
NEO4J_USERNAME=neo4j
NEO4J_PASSWORD=your-password
NEO4J_DATABASE=neo4j
```

The full configuration file is published to `config/neo4j.php` and includes options for:

- Multiple connections
- Connection pooling
- Query caching
- SSL/TLS settings
- Migration paths

Usage
-----

[](#usage)

### Basic Queries

[](#basic-queries)

Using the facade:

```
use SignalNorth\LaravelNeo4j\Facades\Neo4j;

// Create a node
Neo4j::statement('CREATE (u:User {name: $name, email: $email})', [
    'name' => 'John Doe',
    'email' => 'john@example.com'
]);

// Query nodes
$users = Neo4j::select('MATCH (u:User) RETURN u');

// Update nodes
Neo4j::update('MATCH (u:User {email: $email}) SET u.name = $name', [
    'email' => 'john@example.com',
    'name' => 'Jane Doe'
]);

// Delete nodes
Neo4j::delete('MATCH (u:User {email: $email}) DELETE u', [
    'email' => 'john@example.com'
]);
```

### Using Query Builder

[](#using-query-builder)

```
use Illuminate\Support\Facades\DB;

// Get all users
$users = DB::connection('neo4j')
    ->table('User')
    ->get();

// Find specific user
$user = DB::connection('neo4j')
    ->table('User')
    ->where('email', 'john@example.com')
    ->first();

// Create relationships
DB::connection('neo4j')->statement('
    MATCH (u:User {id: $userId}), (p:Product {id: $productId})
    CREATE (u)-[:PURCHASED {date: datetime()}]->(p)
', [
    'userId' => 1,
    'productId' => 100
]);
```

### Migrations

[](#migrations)

Create a new migration:

```
php artisan neo4j:make:migration create_user_nodes --create=User
```

Example migration:

```
