PHPackages                             anshu-krishna/neo4j-bolt - 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. anshu-krishna/neo4j-bolt

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

anshu-krishna/neo4j-bolt
========================

PHP driver for Bolt protocol for communication with Neo4j graph database over TCP

2.0(3y ago)020MITPHPPHP &gt;=8.1

Since Sep 1Pushed 3y ago1 watchersCompare

[ Source](https://github.com/anshu-krishna/Neo4j-Bolt)[ Packagist](https://packagist.org/packages/anshu-krishna/neo4j-bolt)[ RSS](/packages/anshu-krishna-neo4j-bolt/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (4)Used By (0)

Krishna-Neo4j-Bolt
==================

[](#krishna-neo4j-bolt)

PHP driver for Bolt protocol for communication with Neo4j graph database over TCP

Installation:
-------------

[](#installation)

```
composer require anshu-krishna/neo4j-bolt

```

Requirements:
-------------

[](#requirements)

- PHP &gt;= 8.1
- Neo4j (with Bolt version 4.4, 4.3, 4.2 or 4.1)

**Note: All examples use the Neo4j 'Example Movie Database'**

Example:
--------

[](#example)

```
require_once "vendor/autoload.php";

use Krishna\Neo4j\{AuthToken, BoltMaker};
use Krishna\Neo4j\Protocol\Reply\Success;

// Create Bolt
$bolt = (new BoltMaker(
	auth: AuthToken::basic('neo4j', 'neo4j')
))->makeBolt();

echo 'Running Bolt version:', $bolt::VERSION, '';

// Run Query
$run = $bolt->query(message;
	exit(0);
}

echo roles);
		echo person->properties['born']}
	{$roles}
	{$i->movie['title']}
	{$i->movie['year']}

ROW;
	}

echo '';
```

**For specifc BOLT version:**

Use the `useVersion()` in `BoltMaker` to set upto 4 versions in order of preference.

```
$bolt = (new BoltMaker(auth: AuthToken::basic('neo4j', 'neo4j')))
	->useVersion(E_Version::V4_2, E_Version::V4_1)
	->makeBolt();
var_dump($bolt::VERSION);
```

**Debug Logging:**

Pass a `Logger` object in `BoltMaker` for protocol debug logs.

```
$bolt = (new BoltMaker(
	auth: AuthToken::basic('neo4j', 'neo4j'),
	logger: new Logger(rowSize: 20)
))->makeBolt();
```

Output:

```
Write [Handshake]:
60 60 b0 17  00 00 04 04  00 00 03 04  00 00 02 04  00 00 01 04

Read [Handshake]:
00 00 04 04

Write [Hello]:
00 01 b1 00  01 01 a4 8a  75 73 65 72  5f 61 67 65  6e 74 89 4b
42 6f 6c 74  2f 31 2e 30  86 73 63 68  65 6d 65 85  62 61 73 69
63 89 70 72  69 6e 63 69  70 61 6c 85  6e 65 6f 34  6a 8b 63 72
65 64 65 6e  74 69 61 6c  73 85 6e 65  6f 34 6a 00  00

Read [Hello = Success]:
b1 70 a3 86  73 65 72 76  65 72 8b 4e  65 6f 34 6a  2f 34 2e 34
2e 35 8d 63  6f 6e 6e 65  63 74 69 6f  6e 5f 69 64  87 62 6f 6c
74 2d 31 38  85 68 69 6e  74 73 a0

Write [Goodbye]:
00 01 b0 00  01 02 00 00

```

To start logging after creating a `Bolt` protocol:

```
$bolt = (new BoltMaker(
	auth: AuthToken::basic('neo4j', 'neo4j')
))->makeBolt();

// Start logging
$bolt->logger = new Logger;

// Execute quries here

// Stop logging
$bolt->logger = null;
```

Protocol functions:
-------------------

[](#protocol-functions)

- Run a query

    ```
     function query(
     	string $query,
     	array $parameters = [],
     	bool $autoResetOnFaiure = true,
     	array $bookmarks = [],
     	int $tx_timeout = -1,
     	?array $tx_metadata = null,
     	bool $readMode = false,
     	?string $db = null
     ): I_Reply;
    ```
- Pull results

    ```
     function pull(int $count = -1, int $qid = -1);
     /* qid is query id */
    ```
- Disconnect

    ```
     function disconnect(): void;
    ```
- Reset connection

    ```
     function reset(): I_Reply;
    ```
- Start a transaction

    ```
     function beginTransaction(
     	array $bookmarks = [],
     	int $tx_timeout = -1,
     	?array $tx_metadata = null,
     	bool $readMode = false,
     	?string $db = null
     ): I_Reply;
    ```
- Commit transaction

    ```
     function commit(): I_Reply;
    ```
- Rollback transaction

    ```
     function rollback(): I_Reply;
    ```
- Get last query metadata

    ```
     function getQueryMeta(): ?I_Reply;
    ```
- Check if last query was valid

    ```
     function queryValid(): bool;
    ```
- Check if last query has more results

    ```
     function moreResults(): bool;
    ```
- Discard results

    ```
     function discard(int $count = -1, int $qid = -1): ?I_Reply;
     /* qid is query id */
    ```

**Only in `Bolt` &gt;= 4.3**

- Send route message ```
     function route(array $routing, array $bookmarks, ?string $db = null): I_Reply;
    ```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~5 days

Total

3

Last Release

1339d ago

Major Versions

1.0.1 → 2.02022-09-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c583afac6200755c7e2326c965ef0fcc382f4f7448f9459af6732358fc0b7fb?d=identicon)[anshu-krishna](/maintainers/anshu-krishna)

---

Top Contributors

[![anshu-krishna](https://avatars.githubusercontent.com/u/4680045?v=4)](https://github.com/anshu-krishna "anshu-krishna (41 commits)")

---

Tags

boltbolt41bolt42bolt43bolt44databasedatabase-driverdrivergraphdatabaseneo4jphp81databaseSocketneo4jbolt

### Embed Badge

![Health badge](/badges/anshu-krishna-neo4j-bolt/health.svg)

```
[![Health](https://phpackages.com/badges/anshu-krishna-neo4j-bolt/health.svg)](https://phpackages.com/packages/anshu-krishna-neo4j-bolt)
```

###  Alternatives

[stefanak-michal/bolt

PHP library to provide connectivity to graph database over TCP socket with Bolt specification

79655.8k8](/packages/stefanak-michal-bolt)[vinelab/neoeloquent

Laravel wrapper for the Neo4j graph database REST interface

65393.1k1](/packages/vinelab-neoeloquent)[graphaware/neo4j-common

Common Utilities library for Neo4j

24876.2k24](/packages/graphaware-neo4j-common)[neo4j/neo4j-bundle

Symfony integration for Neo4j

8272.1k](/packages/neo4j-neo4j-bundle)[ulobby/neoeloquent

Laravel wrapper for the Neo4j graph database REST interface

4473.4k](/packages/ulobby-neoeloquent)[heydavid713/neo4jphp

Wrapper for the Neo4j graph database REST interface

12106.5k10](/packages/heydavid713-neo4jphp)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
