KEMBAR78
Neo4j Graph Database, from PHP | ODP
Neo4j Graph Database
      From PHP

  February 28, 2013
   Confoo 2013, Montréal
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?
Neo4j
            Out 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
â—Ź   Can modify the graph
â—Ź   Allows to run arbitrary code
â—Ź   Implementation not as stable in Neo4j
Cypher

START doctor = node(1)
MATCH
 doctor <-[:COMPANION_OF]- companion,
 companion -[:APPEARED_IN]-> episode
WHERE
 episode.title = "The Doctor's Daughter"
RETURN companion, companion.character
Enough theory

Neo4j in action
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:                 Cons:
â—Ź   Well maintained   â—Ź   Tedious API
â—Ź   Good              â—Ź   Error-prone
    documentation     â—Ź   Low-level
â—Ź   Predictable
    behavior
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:                        Cons:
â—Ź   Fast (bulk operations)   â—Ź   Supported by me
â—Ź   Feels like Doctrine      â—Ź   Skim
â—Ź   Benefits from type           documentation
    checking                 â—Ź   Implementation still
â—Ź   Well tested                  partial
â—Ź   Bundles and
    modules available
    (many)
Others
â—Ź   neoxygen/updown
â—Ź   neoxygen/neox
â—Ź   neoxygen/GraphQuest
Demo




                 Code
https://github.com/lphuberdeau/confoo-demo
Contact



Louis-Philippe Huberdeau
      lp@huberdeau.info

Neo4j Graph Database, from PHP

  • 1.
    Neo4j Graph Database From PHP February 28, 2013 Confoo 2013, Montréal
  • 2.
    How I gothere R.I.P. Had a short life, but left before it was too late.
  • 3.
    Why Neo4j? ● Simple set-up ● Well documented ● Open source ● ... with “Enterprise” support ● Not purely academic
  • 4.
    What is agraph database? A database providing persistance for graphs.
  • 5.
    Ok, but whatis a graph?
  • 6.
    Ok, but whatis a graph?
  • 7.
    Neo4j Out of the Box Data: http://www.neo4j.org/develop/example_data
  • 8.
    Gremlin ● Provides control over the traversal algorithm ● Pipe & Filter – similar to jQuery ● Works across different graph databases ● Based on Groovy (limited to Java)
  • 9.
    Gremlin g.v(1) .in('COMPANION_OF') .out('APPEARED_IN') .has('title', "The Doctor's Daughter") .back(2)
  • 10.
    Gremlin â—Ź Can modify the graph â—Ź Allows to run arbitrary code â—Ź Implementation not as stable in Neo4j
  • 11.
    Cypher START doctor =node(1) MATCH doctor <-[:COMPANION_OF]- companion, companion -[:APPEARED_IN]-> episode WHERE episode.title = "The Doctor's Daughter" RETURN companion, companion.character
  • 12.
  • 13.
    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
  • 14.
    everyman/neo4jphp â—Ź Complete? REST API implementation â—Ź Basic wrappers for all components â—Ź https://github.com/jadell/neo4jphp/wiki
  • 15.
    everyman/neo4jphp Pros: Cons: â—Ź Well maintained â—Ź Tedious API â—Ź Good â—Ź Error-prone documentation â—Ź Low-level â—Ź Predictable behavior
  • 16.
    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
  • 17.
    hirevoice/neo4jphp-ogm Pros: Cons: â—Ź Fast (bulk operations) â—Ź Supported by me â—Ź Feels like Doctrine â—Ź Skim â—Ź Benefits from type documentation checking â—Ź Implementation still â—Ź Well tested partial â—Ź Bundles and modules available (many)
  • 18.
    Others â—Ź neoxygen/updown â—Ź neoxygen/neox â—Ź neoxygen/GraphQuest
  • 19.
    Demo Code https://github.com/lphuberdeau/confoo-demo
  • 20.