Symfony CMF – Shaking the Tree(Bundle)

The Symfony CMF project is an open source project based on Symfony2 and meant to provide a common ground to build PHP CMS’ upon. All along 2011, ideato supported the Symfony CMF by coding, discussing features and hosting related events. Since Septemper I have been dedicating as many hours as my agile & lean coaching activity allowed to this project and, while trying and striving to help sorting issues out – which, I admit, I’d like to have more time to do, because I like it – I decided to focus on providing the community with some tree-browsing tool.

What do you mean with ‘browsing’? you may ask, since you may already suspect that browsing content in a CMF based website is something usually done with a web browser! And you were right, though here I mean something apt to previewing the structure of nodes within a content tree stored in a PHPCR repository, the very heart of any Symfony CMF powered project.

We needed some Javascript to render a tree structure on the front end and some server-side interface to the repository to get nodes’ children as per clicked on the tree. A lazy nodes loading strategy would add some performance sugar in case of very deep and wide content trees. I decided to write two seperate bundles.

The first bundle, called TreeBundle, wraps a well known Javascript library up – called jQuery Treeview – with the intent not to reinvent the wheel. There are a few good Javascript libraries out there managing the nasty-enough task to render and update a dynamic HTML tree: that one proved to be easy and straight to wrap within a bundle, just depending on jQuery.

On the server side, after some sinful overengineering, the solution came out to be as easy as to provide a JSON array of any requested node’s children, with a light touch of PHPUnit tests. PHPCRBrowserBundle is in charge of encapsulating those features.

I published on YouTube a few screencasts to show the bundle in action.

Now what? It would be nice to include some templating feature and some way to decorate & show the node content, but by now ideato‘s decision is to join Nacho Martìn in his effort to develop the SonataDoctrinePHPCRAdminBundle. He is doing a great job, setting a milestone in CMF development, and I think every minute I’ll be able to spend helping him will be worth.

First step? Integrating the tree browser in the admin bundle! Anyone willing to help?