neo4j-php/neo4j-laravel
Integrate Neo4j graph databases into Laravel with configuration, service provider wiring, and convenient query support for building graph-backed applications alongside your existing Laravel stack.
config/database.php alongside your existing connections (a neo4j block with host, credentials, and auth mode). Because it's a real database driver, this is the natural first place to look.file. Using Neo4j as the default connection does not support Laravel authentication — Laravel's session/user tables won't exist in the graph. Set SESSION_DRIVER=file and leave auth on a relational connection.DB facade — DB::connection('neo4j')->select(...) or runCypher() — before layering the query builder or Eloquent on top. This validates driver config, TLS, and auth in one step.ClientInterface, DriverInterface, SessionInterface, and TransactionInterface resolve from the container, so you can pull the raw driver/session for diagnostics or to drop down to driver-level calls.Neo4jModel with a node label and use elementId() as the key.DB: select(), insert(), update(), delete(), statement() for Laravel-shaped calls, plus read()/write()/runCypher() when you want explicit read/write intent (useful for routing and cluster behavior).? positional bindings and let the package map them to named $pN parameters. Booleans stay booleans, so you don't need the SQL-style 1/0 workarounds.groupBy, unions, and whereIn/whereExists subqueries — this is where you get Laravel ergonomics without hand-writing Cypher.whereVectorSimilarTo() queries a Neo4j vector index. This is the headline pattern for semantic search / RAG features; pair it with application-level embedding generation.matchRelationship() and insertRelationship(), including several matchRelationship() calls on a single query for multi-hop traversals.insertRelationships(), upsertRelationships(), syncRelationships(), deleteRelationships(). Use these in seeders and importers instead of looping single writes.Neo4jModel with a node label; standard relationship types (hasOne, hasMany, belongsToMany, hasOneThrough, hasManyThrough) plus full morph support (morphOne, morphMany, morphTo, morphToMany). Model-level matchRelationship() with create, attach, sync, detach mirrors familiar pivot workflows.upsert() plus the relationship upsert/sync variants for idempotent sync jobs.beginTransaction/commit/rollBack for multi-statement writes, with connection and transaction timeouts configured per connection.useDatabase() — handy for multi-tenant graphs or environment isolation.NEO4J_QUERY_CHANNEL controls per-request query log flushing for correlation in logs.SESSION_DRIVER=file and don't point AUTH at the graph.id(). Neo4j nodes use elementId(). Anywhere you'd reach for $model->id, use the element id — don't assume integer auto-increment keys.SET clauses as qualified names (User.updated_at → n.updated_at). If you customize timestamp handling, keep the qualification consistent or updates will write the wrong property.runCypher() and centralize those queries so they're easy to audit and migrate.? becomes $pN in logs, slow-query output, and copied Cypher. Don't be surprised when the query you see isn't the query you typed.whereVectorSimilarTo() needs an actual Neo4j vector index; there's no migration support mentioned, so plan a Cypher DDL bootstrap step outside Laravel migrations for labels, indexes, and constraints.matchRelationship() calls on one query, verify the generated Cypher via Debugbar or query events before trusting the results.ClientInterface, DriverInterface, SessionInterface, TransactionInterface) as seams for testing and future-proofing.NEO4J_QUERY_CHANNEL governs per-request flushing when you're correlating queries from logs.How can I help you explore Laravel packages today?