Slide 1

Slide 1 text

A decoupled Content Management Framework 14 november - 010PHP

Slide 2

Slide 2 text

Willem-Jan Zijderveld Developer at Beeldspraak @willemjanz github.com/wjzijderveld blog.willem-jan.net

Slide 3

Slide 3 text

In this talk What is Symfony CMF Under the hood: PHPCR The components What's brewing

Slide 4

Slide 4 text

What is Symfony CMF Toolbox Aimed at developers Set of bundles Scalability Usability Documentation Testing Community Driven

Slide 5

Slide 5 text

Under the hood: PHPCR

Slide 6

Slide 6 text

PHP Content Repository Proven technique Defines a interface Decouple the storage from you application Lots of features

Slide 7

Slide 7 text

PHPCR Interface any PHP content management application with any content repository

Slide 8

Slide 8 text

PHPCR Write applications once, switch storage backends when needed

Slide 9

Slide 9 text

PHPCR: Quick overview Store content in a tree of nodes Each node has a name and a type Nodes can have children Nodes can have properties with values A value can be almost anything

Slide 10

Slide 10 text

Best of both worlds RDBMS Transactions Query Structure Integrity Filesystem Binary Hierarchy Locking Access Control And more Unstructured Versioning Full-Text Multi-value

Slide 11

Slide 11 text

Example < j c r : r o o t > < c m s > < p a g e s > < h o m e t i t l e = " H o m e p a g e " > < b l o c k t i t l e = " N e w s " c o n t e n t = " T o d a y : S y m f o n y C M F p r e s e n t a t i o n " / > < / h o m e > < c o n t a c t t i t l e = " C o n t a c t " c o n t e n t = " s y m f o n y - c m f - d e v s @ g o o g l e g r o u p s . c o m " / > < / p a g e s > < / c m s > < / j c r : r o o t > Node home Path: /cms/pages/home Parent: /cms/pages Name: home

Slide 12

Slide 12 text

Doctrine PHPCR ODM Object to Document mapper Persist your objects as PHPCR nodes

Slide 13

Slide 13 text

I thought this talk was about Symfony CMF?

Slide 14

Slide 14 text

The components CoreBundle Routing + RoutingBundle ContentBundle BlockBundle CreateBundle MediaBundle MenuBundle

Slide 15

Slide 15 text

CoreBundle Publish Workflow Templating Multi-language support More...

Slide 16

Slide 16 text

CoreBunde Publish Workflow Implement your publication workflow Uses Symfony Security Component with Access Voters

Slide 17

Slide 17 text

Article.php MyController.php < ? p h p c l a s s A r t i c l e i m p l e m e n t s P u b l i s h a b l e I n t e r f a c e , P u b l i s h T i m e P e r i o d I n t e r f a c e { / * * @ v a r \ D a t e T i m e * / p r i v a t e $ i s P u b l i s h a b l e ; p u b l i c f u n c t i o n i s P u b l i s h a b l e ( ) { r e t u r n $ t h i s - > i s P u b l i s h a b l e ; } } < ? p h p / / c h e c k i f c u r r e n t u s e r i s a l l o w e d t o s e e t h i s d o c u m e n t $ p w c = $ c o n t a i n e r - > g e t ( ' c m f _ c o r e . p u b l i s h _ w o r k f l o w . c h e c k e r ' ) ; i f ( ! $ p w c - > i s G r a n t e d ( P u b l i s h W o r k f l o w C h e c k e r : : V I E W _ A T T R I B U T E , $ d o c u m e n t ) ) { / / f . e . r e d i r e c t t o 4 0 4 } Most of the time, this is handled by the RequestListener

Slide 18

Slide 18 text

CoreBundle Templating Provides some basic helpers cmf_is_published cmf_children cmf_next/cmf_prev ...

Slide 19

Slide 19 text

CoreBundle Templating { % f o r n e w s I t e m i n c m f _ c h i l d r e n ( p a g e ) | r e v e r s e % } < l i > < a h r e f = " { { p a t h ( n e w s I t e m ) } } " > { { n e w s I t e m . t i t l e } } < / a > ( { { n e w s I t e m . p u b l i s h S t a r t D a t e | d a t e ( ' Y - m - d ' ) } } ) < / l i > { % e n d f o r % }

Slide 20

Slide 20 text

CoreBundle Multi-language support Configuration for all Bundles TranslatableInterface

Slide 21

Slide 21 text

Routing + RoutingBundle Extends Symfony Routing Component Introduces ChainRouter Has the possibility to load routes from the database Bundle simply integrates the component

Slide 22

Slide 22 text

ChainRouter Add prioritized routers Stops on first match Can use the full Request

Slide 23

Slide 23 text

Dynamic Router Lookup routes in your database Generate URLs based on path or object

Slide 24

Slide 24 text

Enhance your routes RouteContentEnhancer FieldMapEnchancer FieldByClassEnhancer FieldPresenceEnhancer

Slide 25

Slide 25 text

RouteContentEnhancer When the found route is an instance of RouteObjectInterface < ? p h p c l a s s R o u t e i m p l e m e n t s R o u t e O b j e c t I n t e r f a c e { } Set's the contentDocument in the route < ? p h p $ r o u t e - > g e t C o n t e n t ( ) ; ? >

Slide 26

Slide 26 text

FieldMapEnhancer Sets a value in the route, based on a hashmap < ? p h p u s e S y m f o n y \ C m f \ C o m p o n e n t \ R o u t i n g \ E n h a n c e r \ F i e l d M a p E n h a n c e r ; $ h a s h M a p = a r r a y ( ' f o o ' = > ' 0 1 0 P H P ' ) ; $ e n h a n c e r = n e w F i e l d M a p E n h a n c e r ( ' b a r ' , ' t i t l e ' , $ h a s h M a p ) ; Imagine a Route, that has a property bar with value foo After the enhancer is applied, the route will also have a property title with value 010PHP

Slide 27

Slide 27 text

FieldByClassEnhancer Looks like FieldMap enhancer Checks with instanceOf instead of comparing value Used to set a controller based on Document

Slide 28

Slide 28 text

FieldPresenceEnhancer Simply set's a value when a field is present Can also be used to set a default value Is used to set the default Controller

Slide 29

Slide 29 text

ContentBundle Default Document Default Controller References routes References menu nodes

Slide 30

Slide 30 text

BlockBundle Create and use blocks of content in your website. Makes perfect sense as childnodes in your Content Repository

Slide 31

Slide 31 text

BlockBundle Common behaviour Aimed at PHPCR Settings Implements PublishableInterface Support Multi-language

Slide 32

Slide 32 text

BlockBundle Available types StringBlock SimpleBlock ContainerBlock ReferenceBlock ActionBlock RssBlock ImagineBlock SlideshowBlock Very easy to create your own block

Slide 33

Slide 33 text

BlockBundle Template usage { { s o n a t a _ b l o c k _ r e n d e r ( { ' n a m e ' : ' p r e s e n t a t i o n B l o c k ' } ) } }

Slide 34

Slide 34 text

CreateBundle Integrates CreateJS and CreatePHP into Symfony2 Uses RDFa meta-data (like Doctrine's mapping) Support for CKEditor and Hallo.js Twig example { % c r e a t e p h p p a g e a s = " r d f " n o a u t o t a g % } < d i v { { c r e a t e p h p _ a t t r i b u t e s ( r d f ) } } > < h 1 c l a s s = " m y - t i t l e " { { c r e a t e p h p _ a t t r i b u t e s ( r d f . t i t l e ) } } > { { c r e a t e p h p _ c o n t e n t ( r d f . t i t l e ) } } < / h 1 > < d i v { { c r e a t e p h p _ a t t r i b u t e s ( r d f . b o d y ) } } > { { c r e a t e p h p _ c o n t e n t ( r d f . b o d y ) } } < / d i v > < / d i v > { % e n d c r e a t e p h p % }

Slide 35

Slide 35 text

MediaBundle Basic documents Controllers for showing and downloading Helper for uploading Adapters for 3rd-party integration LiipImagine elFinder Gaufrette

Slide 36

Slide 36 text

MenuBundle Integrates KnpMenu into Symfony CMF Can point to content or a route

Slide 37

Slide 37 text

MenuBundle { { k n p _ m e n u _ r e n d e r ( ' m a i n - m e n u ' ) } } Simple isn't it?

Slide 38

Slide 38 text

Even more Bundles CmfTreeBrowserBundle CmfBlogBundle CmfSearchBundle CmfSimpleCms LuneticsLocaleBundle SonataDoctrinePhpcrAdminBundle ...

Slide 39

Slide 39 text

What's brewing?

Slide 40

Slide 40 text

1.0 has been released! 1.1 scheduled a month after Symfony 2.4 So somewhere in December

Slide 41

Slide 41 text

Release cycle

Slide 42

Slide 42 text

Who is using it?

Slide 43

Slide 43 text

Contribute!

Slide 44

Slide 44 text

7 / 44 Questions? Freenode: #symfony-cmf http://cmf.symfony.com [email protected]