Symfony CMF - PHP Conference Brazil 2011

4,420 views

Published on

PHP Conference Brazil 2011 keynote about Symfony CMF

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,420
On SlideShare
0
From Embeds
0
Number of Embeds
292
Actions
Shares
0
Downloads
14
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

Symfony CMF - PHP Conference Brazil 2011

  1. 1. Symfony CMF What & Why Jacopo Romei
  2. 2. Jacopo Romei Agile coach 2005 PHP developer 1999 @jacoporomei Symfony2 CMF 2011 since Opensource Symfony1 patches
  3. 3. Tool for developers Not for final users ?
  4. 4. Impedence mismatch NoSQL OOP RDBMS
  5. 6. CMS Drupal Devil is in the details Interaction EZ Publish Not Data/Behavior containers Real OOP architecture
  6. 7. Immagine lord of the rings
  7. 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
  8. 9. Technical debt Refactoring Legacy code Short term Long term Skill
  9. 10. Frameworks create technical debt
  10. 11. CMS systems create more
  11. 12. Common ground Drupal Symfony2 HTTP Foundation Use at will tools
  12. 13. PHPCR Standardized API Core Implementation agnostic JCR Officially in 2.1 specs
  13. 14. PHPCR in the wild Midgard2 Jackalope Doctrine DBAL MongoDB Jackrabbit
  14. 15. PHPCR Features Tree access Access by UUID Search nodes Versioning XML import (*) and export Locking (*) & Transactions Permissions & Access Control (*) Observation (*) (*) ask the speaker
  15. 16. PHPCR Hierarchical storage Workspaces Nodes Properties Primary node types Mixin node types Tree Multiple roots Indipendent trees Unique path Namespaced Types String, URI, bool, long, double, decimal, binary, date, name, path, (weak)reference Folder, file, unstructured, custom Traits PHP5.4? Runtime Mix:referenceable, mix:versionable
  16. 17. Keynote
  17. 18. Keynote Hey! Show us some code! You are a nerd and so we are!
  18. 19. $factory = new JackalopeRepositoryFactoryJackrabbit(); $parameters = array( 'jackalope.jackrabbit_uri' => 'http://localhost:8080/server' ); // end of implementation specific configuration // $repository = $factory->getRepository($parameters); $creds = new PHPCRSimpleCredentials('user','pw'); $session = $repository->login($creds, 'default'); Connect
  19. 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
  20. 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
  21. 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
  22. 23. // make versionable $node = $session->getNode('/site/content/about'); $node->addMixin('mix:versionable'); $session->save(); $vm = $session->getWorkspace()->getVersionManager() // create initial version $node->setProperty('label', 'About'); $session->save(); $vm->checkpoint($node->getPath()); Versioning
  23. 24. // update version $node->setProperty('label', 'Ups'); $session->save(); $vm->checkpoint($node->getPath()); $base = $vm->getBaseVersion($node->getPath()); $previous = array_pop($base->getPredecessors()); $vm->restore(true, $previous->getName(), $node->getPath() ); Versioning 2
  24. 25. $queryManager = $workspace->getQueryManager(); $sql = "SELECT * FROM [nt:unstructured] WHERE [nt:unstructured].type = 'nav' ORDER BY [nt:unstructured].title"; $query = $queryManager->createQuery($sql, 'JCR-SQL2'); $query->setLimit($limit); $query->setOffset($offset); $queryResult = $query->execute(); foreach ($queryResult->getNodes() as $node) { var_dump($node->getPath()); }; SQL2
  25. 26. PHPCR ODM
  26. 28. /** @PHPCRDocument(alias="nav", repositoryClass="NavigationRepository") */ class Navigation { /** @PHPCRId(strategy="repository") */ public $id; /** @PHPCRChildren */ public $children; /** @PHPCRString(name="label") */ private $label; private $internal; ... }; Document class
  27. 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
  28. 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
  29. 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
  30. 32. PHP Community Driving OS projects Growth 90's Skills Symfony2 since Opensource
  31. 33. beberlei (Benjamin Eberlei) bergie (Henri Bergius) brki (Brian King) chirimoya (Thomas Schedler) chregu (Christian Stocker) dbu (David Buchmann) ebi (Tobias Ebnöther) jakuza (Jacopo Romei) justinrainbow (Justin Rainbow) k-fish (Karsten Dambekalns) lapistano (Bastian Feder) lsmith77 (Lukas K. Smith) – Slides! micheleorselli (Michele Orselli) nacmartin (Nacho Martín) nicam (Pascal Helfenstein) ornicar (Thibault Duplessis) piotras robertlemke (Robert Lemke) rndstr (Roland Schilter) Seldaek (Jordi Boggiano) sixty-nine (Daniel Barsotti) uwej711 (Uwe Jäger) vedranzgela (Vedran Zgela)
  32. 34. Bundles PHPCRBrowserBundle TreeBundle SonataDoctrinePhpcrAdminBundle Decoupled Powerful ChainRoutingBundle PHPCRBrowserBundle NavigationBundle ContentBundle
  33. 35. Technical debt Refactoring Legacy code Short term Long term Skill
  34. 36. Symfony CMF wants you
  35. 37. Gift!
  36. 38. __ row, __ seat. Gift!
  37. 39. Thank you
  38. 40. Jacopo Romei [email_address]

×