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.