Getting started with
Content management in Symfony2
About David Buchmann
Twitter: @dbu
David is a senior developper at Liip SA, specializing in Symfony2. He happens to also be a certified Scrum Master and sometimes enjoys doing the scrum master or product owner role for a project.
Liip is doing custom web development with PHP in Switzerland. liip.ch/jobs
The Plan
- Intro (10 min)
- Step by step walk through (70 min, with break)
- Closing (10 min)
Symfony crash intro
- Web framework
- Routing and Controllers
- Services
- Templating: Twig
- Storage: Doctrine ORM, PHPCR-ODM
- Tools: HTTP foundation, Event System, Command Line, Forms, Translations, Debugging, ...
Symfony directories
- app/: the application configuration
- src/: the project's PHP code
- vendor/: the third-party dependencies (composer)
- web/ the web root directory (app_dev.php)
CMF Intro
The Symfony CMF project makes it easier for developers to add CMS functionality to
applications built with the Symfony2 PHP framework. Key development principles for the provided
set of bundles are scalability, usability,
documentation and testing
CMF = Content Management Framework
- A toolbox to create your own custom CMS
- Not a ready-to-use application for end users
- Not a one size fits all, but increase code sharing
- Use what you can
- Replace what you need
- Ignore what you do not need
- Imagine Drupal, ezPublish, Diem, Sympal all build on the same content foundation
Conference Tutorial
- Presentations take place in Rooms
- Presentations are held by one or more Speaker
- We see a schedule and a list of speakers
- We want frontend edting
- We want an administration backend
Doctrine PHPCR-ODM
- PHPCR: Graph-based, schema-less, versioning document database
- Object to Document mapper
- Persist your Objects as PHPCR nodes
- This is not active record
- But you explicitly register plain php class instances with the manager
- Metadata to map from database to class properties
- YAML, XML or php annotations
- No need for interfaces or extending a base class
PHPCR-ODM is not ORM, nor MongoDB or CouchDB ODM
- Tree/graph structure
- Direct access and search
- Translation of documents
- Versioning
- Document and subtree locking
- Standardized XML import/export
- Observation (*)
- Access Control *
* Not yet implemented in Jackalope
Repository Content
<jcr:root>
<cms>
<pages>
<home title="Hello">
<block title="News"
content="Today: PHPCR presentation"/>
</home>
<contact title="Contact"
content="phpcr-users@groups.google.com"/>
</pages>
</cms>
</jcr:root>
Symfony2 Control Flow
Â
Symfony2 Control Flow
CMF additions
Route and template
- Hardcode controller in route object
- Configure by 'type' parameter on route object
- Configure by content class
- Template by content class (default controller)
Questions & Answers
Play with it today!
github.com/dbu/conference-tutorial
Challenge: Build an FAQ page!
Review
- What did you like?
- What can I improve?
- What did you miss?
Thank you!
Contact me on IRC or Twitter @dbu