laudis/neo4j-php-client
Typed Neo4j PHP client/driver with Bolt and Neo4j (auto-routed) support. Intuitive, extensible API with easy configuration, built with input from the official driver team and validated via Neo4j Testkit for reliability.
ClientBuilder) reduce onboarding time. The Bolt protocol (low-latency binary) is preferred over HTTP for PHP.| Risk Area | Severity | Mitigation |
|---|---|---|
| Idempotency in Transactions | High | Requires discipline in transaction design (e.g., avoid side effects outside the transaction). Use readTransaction/writeTransaction for safety. |
| Schema Management | Medium | No Laravel migrations; rely on Cypher scripts or tools like Neo4j Browser. |
| Performance Overhead | Medium | Bolt protocol is efficient, but complex queries may require query tuning (use EXPLAIN and PROFILE). |
| Dependency Lock-in | Low | MIT license; vendor-neutral. Risk of Neo4j driver changes (monitor release notes). |
| Concurrency | Low | Neo4j handles concurrency natively; PHP’s writeTransaction ensures atomicity. |
Data Model Strategy:
User node ↔ User Eloquent model, with relationships as separate tables or graph edges?)Query Complexity:
Operational Requirements:
ClientBuilder).Tooling:
Team Skills:
^2.8 of the driver.ext-bcmath, ext-json, ext-sockets (standard in most Laravel deployments).Pilot Phase:
JOIN-heavy SQL query for "find all friends of friends" with a 2-hop Cypher traversal.Hybrid Integration:
// app/Repositories/Graph/Neo4jRepository.php
class Neo4jRepository {
protected $client;
public function __construct(ClientInterface $client) {
$this->client = $client;
}
public function getUserFriends(string $userId): array {
return $this->client->readTransaction(fn($tx) =>
$tx->run("MATCH (u:User {id: \$userId})-[:FRIENDS_WITH]->(friend) RETURN friend", ['userId' => $userId])
->toArray()
);
}
}
AppServiceProvider:
$this->app->bind(Neo4jRepository::class, function($app) {
return new Neo4jRepository($app->make(ClientInterface::class));
});
Full Adoption:
user.created → create Neo4j node).db.index.fulltext (Neo4j 4.4+).CALL gds.* procedures (requires Neo4j Graph Data Science library).DateTime types in the driver.Phase 1: Read-Only Integration (2–4 weeks):
Phase 2: Hybrid Writes (3–6 weeks):
MERGE instead of CREATE to avoid duplicates.Phase 3: Full Graph Model (4–8 weeks):
Phase 4: Optimization (Ongoing):
EXPLAIN and PROFILE.CREATE INDEX FOR (u:User) ON (u.email)).database/neo4j).laudis/neo4j-php-client for breaking changes (e.g., Neo4j 5How can I help you explore Laravel packages today?