Your SlideShare is downloading. ×
Symfony CMF - PHP Conference Brazil 2011
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Introducing the official SlideShare app

Stunning, full-screen experience for iPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Symfony CMF - PHP Conference Brazil 2011

3,780
views

Published on

PHP Conference Brazil 2011 keynote about Symfony CMF

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
3,780
On Slideshare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
12
Comments
0
Likes
4
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Symfony CMF What & Why Jacopo Romei
  • 2. Jacopo Romei Agile coach 2005 PHP developer 1999 @jacoporomei Symfony2 CMF 2011 since Opensource Symfony1 patches
  • 3. Tool for developers Not for final users ?
  • 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
  • 7. Immagine lord of the rings
  • 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
  • 10. Frameworks create technical debt
  • 11. CMS systems create more
  • 12. Common ground Drupal Symfony2 HTTP Foundation Use at will tools
  • 13. PHPCR Standardized API Core Implementation agnostic JCR Officially in 2.1 specs
  • 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
  • 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
  • 17. Keynote
  • 18. Keynote Hey! Show us some code! You are a nerd and so we are!
  • 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
  • 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
  • 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
  • 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
  • 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
  • 26. PHPCR ODM
  • 27.  
  • 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
  • 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
  • 32. PHP Community Driving OS projects Growth 90's Skills Symfony2 since Opensource
  • 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)
  • 34. Bundles PHPCRBrowserBundle TreeBundle SonataDoctrinePhpcrAdminBundle Decoupled Powerful ChainRoutingBundle PHPCRBrowserBundle NavigationBundle ContentBundle
  • 35. Technical debt Refactoring Legacy code Short term Long term Skill
  • 36. Symfony CMF wants you
  • 37. Gift!
  • 38. __ row, __ seat. Gift!
  • 39. Thank you
  • 40. Jacopo Romei [email_address]