Neo4j Graph DatabaseFrom PHP
February 28, 2013
Confoo 2013, Montral
About me
Writing PHP since... 2001?
Consultant since 2006
Graduated in software engineering in 2008
How I got here
R.I.P.Had a short life, but left before it was too late.
Why Neo4j?
Simple set-up
Well documented
Open source
... with Enterprise support
Not purely academic
What is a graph database?
A database providing persistance for graphs.
Ok, but what is a graph?
Ok, but what is a graph?
Ok, but what is a graph?
Many to many relations
Properties on nodes and relations
Path finding algorithms
Neo4jOut of the Box
Data: http://www.neo4j.org/develop/example_data
Gremlin
Provides control over the traversal algorithm
Pipe & Filter similar to jQuery
Works across different graph databases
Based on Groovy (limited to Java)
Gremlin
g.v(1) .in('COMPANION_OF') .out('APPEARED_IN') .has('title', "The Doctor's Daughter") .back(2)
Gremlin
g.v(1) .in('COMPANION_OF').as('companion') .out('APPEARED_IN') .has('title', "The Doctor's Daughter") .back('companion')
Gremlin
Can modify the graph
Allows to run arbitrary code
Implementation not as stable in Neo4j
Cypher
The SQL for graph databases
Simpler to read
Neo4j only
Well supported
Cypher
START doctor = node(1)MATCH doctor episodeWHERE episode.title = "The Doctor's Daughter"RETURN companion, companion.character
Enough theory
Neo4j in action
Accessing from PHP
REST API
JSON over HTTP
Well supported
Used by the web admin
Meaningful work requires many HTTP requests
http://docs.neo4j.org/chunked/stable/rest-api.html
everyman/neo4jphp
Complete? REST API implementation
Basic wrappers for all components
https://github.com/jadell/neo4jphp/wiki
everyman/neo4jphp
Pros:Well maintained
Good documentation
Predictable behavior
Cons:Tedious API
Error-prone
Low-level
hirevoice/neo4jphp-ogm
Bias: I am the author
Inspired by Doctrine
Uses annotations on classes
Built on top of everyman/neo4jphp
https://github.com/lphuberdeau/Neo4j-PHP-OGM
hirevoice/neo4jphp-ogm
Pros:Fast (bulk operations)
Feels like Doctrine
Benefits from type checking
Well tested
Bundles and modules available (many)
Cons:Supported by me
Skim documentation
Implementation still partial
Others
neoxygen/updown
neoxygen/neox
neoxygen/GraphQuest
Demo
Codehttps://github.com/lphuberdeau/confoo-demo
Louis-Philippe [email protected]
Contact
Top Related