venusian-voyager / graph
Neo4j graph driver and Instrument models for Venusian (companion to voyager/database).
Requires
- php: ^8.4|^8.5
- venusian-voyager/collections: ^0.10.0
- venusian-voyager/database: ^0.10.0
- venusian-voyager/nuts-and-bolts: ^0.10.0
Requires (Dev)
None
Suggests
- laudis/neo4j-php-client: Required to open Neo4j connections via Neo4jConnector (^3.3).
- venusian-voyager/console: Required to use the make:graph-model command (^0.10.0).
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-09-30 16:21:15 UTC
README
Neo4j driver for voyager/database. GraphServiceProvider is in
DefaultProviders; the connection is database.connections.neo4j.
Requirements
- PHP
^8.4|^8.5 voyager/database,voyager/contracts,voyager/nuts-and-boltslaudis/neo4j-php-client^3.3, needed once a neo4j connection opens
Raw Cypher
cypher_run('CREATE (n:Person {id: $id, name: $name})', ['id' => 'p1', 'name' => 'Ada']); $records = cypher('MATCH (n:Person) WHERE n.name = ? RETURN n', ['Ada']);
Named ($id) or positional (?) parameters. A ? inside a string or backticked name stays a character.
Models
use Voyager\Graph\Instrument\Model; class Person extends Model { protected $table = 'Person'; } Person::create(['id' => 'p1', 'name' => 'Ada']); Person::where('name', 'like', 'a%')->orderBy('name')->get();
Table = label, columns = node properties, key = string id, no auto-increment.
The builder compiles to Cypher, matching the label as n:
| Builder | Cypher |
|---|---|
get() |
MATCH (n:Label) WHERE … RETURN n ORDER BY … SKIP … LIMIT … |
insert() |
UNWIND [{…}] AS row CREATE (n:Label) SET n = row |
update() |
MATCH … SET n.a = ? RETURN count(n) AS affected |
delete() |
MATCH … DETACH DELETE n RETURN count(n) AS affected |
upsert() |
UNWIND … MERGE (n:Label {key: row.key}) ON CREATE SET n = row ON MATCH SET … |
Wheres: basic, like/whereLike (Cypher regex; like ignores case), in, null,
between, column, nested, raw. Update/delete return nodes touched. Lists are
native list properties.
No single-label form, so refused by name: joins, groupBy, having, unions, locks,
eager-load limits, date/JSON/fulltext/exists wheres. Write those in cypher().
Async
Same as any voyager/database connection: via() runs terminals in a worker,
via()->transaction() a whole transaction, stream() sends db-chunk:neo4j:{label} mail.
Blocking calls on the connection wait for its offloaded writes.
Generate a model: php computer make:graph-model Person --label=Person.