8. The F in CM F 1. a : a basic conceptional structure (as of ideas) b : a skeletal, openwork , or structural frame 2. the larger branches of a tree that determine its shape -- Merriam-Webster Dictionary
9. Technical debt Refactoring Legacy code Short term Long term Skill
14. PHPCR in the wild Midgard2 Jackalope Doctrine DBAL MongoDB Jackrabbit
15. PHPCR Features Tree access Access by UUID Search nodes Versioning XML import (*) and export Locking (*) & Transactions Permissions & Access Control (*) Observation (*) (*) ask the speaker
19. $factory = new ackalopeepositoryFactoryJackrabbit(); $parameters = array( 'jackalope.jackrabbit_uri' => 'http://localhost:8080/server' ); // end of implementation specific configuration // $repository = $factory->getRepository($parameters); $creds = new HPCRimpleCredentials('user','pw'); $session = $repository->login($creds, 'default'); Connect
20. $root = $session->getRootNode(); // Node always added as child of another node $node = $root->addNode('test', 'nt:unstructured'); // Create or update a property $node->setProperty('prop', 'value'); // Persist the changes $session->save(); // Delete a node and all its children $node->remove(); $session->save(); CRUD
21. $node = $session->getNode('/site/content'); foreach ($node->getChildren() as $child) { var_dump($child->getName()); } // or in short foreach ($node as $child) { var_dump($child->getName()); } // filter on node names foreach ($node->getChildren('di*') as $child) { var_dump($child->getName()); }; Tree API
22. $node = $session->getNode('/site/content/about'); $i = 0; $breadcrumb = array(); // note this code doesn't handle graphs do { $i++; $parent = $node->getAncestor($i); $breadcrumb[$parent->getPath()] = $parent->getPropertyValue('label'); } while ($parent != $node); Tree API 2
29. // Create $doc = new Navigation(); $doc->setLabel($label); // no active record. newly created document needs // to be registered it with the document manager $docManager->persist($doc); $docManager->flush(); $id = $doc->id; CRUD
30. // Read $repo = $docManager->getRepository('Navigation'); $doc = $repo->find($id); // Update $doc->setLabel('home'); // no need to call persist() here, document already known $docManager->flush(); // Remove $docManager->remove($doc); $docManager->flush(); CRUD 2
31. reloaded Impedance mismatch PHPCR is no silver bullet Reports on RDBMS To each its own Unstructured data on PHPCR Reports on RDBMS Product price Product description