ACID transactions ▪ Scalable, up to several billion nodes/relationships/properties ▪ Cypher, a human readable query language ▪ REST interface or Java API Features
▪ Written in PHP ▪ Abstracts cURL requests behind a wrapper ▪ Installation using GitHub / Composer ▪ Easy to use ▪ Implemented in many other projects ▪ github.com/jadell/neo4jphp
on localhost $client = new Everyman\Neo4j\Client(); // create a new node $arthur = $client->makeNode(); $arthur->setProperty('name', 'Frank') ->setProperty('title', 'Software Engineer') ->setProperty('company', 'YMC') ->save(); // get ID from Neo4j $arthurId = $arthur->getId();
in PHP ▪ Provides entity mapping using annotations ▪ Installation using GitHub / Composer ▪ Similar to Doctrine ORM ▪ Implements doctrine/common ▪ github.com/lphuberdeau/Neo4j-PHP-OGM
▪ ManyToMany use HireVoice\Neo4j\Annotation as OGM; class MyEntity { /** * @OGM\Property(format="date") */ protected $releaseDate; } Available annotations
▪ ManyToMany use HireVoice\Neo4j\Annotation as OGM; class MyEntity { /** * @OGM\ManyToOne(relation="acts-in") */ protected $mainActor; } Available annotations
in $em $repository = $em->getRepository('Entity\\User'); // Find a User by a specific field $user = $repository->findOneByFullName('superman'); // Returns a User object // Find some users by a specific field $usersFromFrance = $repository->findByCountry('FR'); // Returns a collection // Find one User with more than one criteria $nonActiveWithSuchEmail = $repository->findOneBy(array( 'status' => 'idle', 'email' => '[email protected]') ); // Returns a collection
$eventManager->addEventListener( array('prePersist'), // array of all listened events $listener // instance of your event listener ); $entityManager->setEventManager($eventManager); Create event manager
postPersist - Fires after an entity is persisted ▪ preRelationCreate - Fires before a relation is created ▪ postRelationCreate - Fires after a relation is created ▪ preStmtExecute - Fires before a statement (query) is executed ▪ postStmtExecute - Fires after a statement (query) is executed ▪ preRemove - Fires before an entity is removed ▪ postRemove - Fires after an entity is removed ▪ preRelationRemove - Fires before a relation is removed ▪ postRelationRemove - Fires after a relation is removed Available events
fast ◦ actively maintained ◦ big community ▪ PHP ◦ ...is the most common scripting language for the web ◦ widely used ◦ big community ◦ other great persistence libs in PHP to learn from Neo4j and PHP